0

I have a post request that works fine with postman and I try to convert it into a cUrl request to use it through prompt command or import into Postman.

enter image description here

if the "KEY" field is empty it won't work.

Here is what I tried : curl --header "Content-Type: x-www-form-urlencoded" \ --request POST \ --data '{"resource":"https://xxxxx.com/resources","scope": "openid","client_id":"xxx-xxx-x-xxx","client_secret":"xxxx-xxxxxx-xxxx"}' \ https://xxxxx-xxxxx.com/api/token

in Postman the result is "Bad request".

Thanks for your help.

Njdc Wide
  • 21
  • 3
  • Does this answer your question? [Converting a POSTMAN request to Curl](https://stackoverflow.com/questions/49432735/converting-a-postman-request-to-curl) – tommy.carstensen Jul 07 '22 at 11:04

1 Answers1

0

You can get any request as curl from postman. It will be generated automatically. You should follow below two images for getting curl request code. enter image description here

enter image description here

Ariful Islam
  • 696
  • 6
  • 11
  • Fantastic ! thanks !! – Njdc Wide Dec 07 '21 at 11:09
  • yes. This is a built in feature of postman. really awesome – Ariful Islam Dec 07 '21 at 11:10
  • It is working with Postman but unfortunately it does't work when I copy/paste the curl code generated by Postman into a Windows command prompt. At the end I just try to get a response from an API. – Njdc Wide Dec 07 '21 at 12:03
  • its working in linux . – Ariful Islam Dec 07 '21 at 12:11
  • but windows may create issues. – Ariful Islam Dec 07 '21 at 12:11
  • This finally works : curl --location --request POST "https://xxxxx.com/api/token?grant_type=client_credentials&resource=https://xxxxxxxxx.com/resources&scope=openid&client_id=xxxx-xxxxx-xxxx-xxxxe&client_secret=xxxxx-xxx-xxxx-xxx" --header "Content-Type: application/x-www-form-urlencoded" . The import thing is to put double quote instead of single one. --location is even not necessary and rhe request is as simple as that. – Njdc Wide Dec 08 '21 at 08:20