By Marin Bînzari


2015-01-15 06:34:46 8 Comments

I a using Postman to test some Curl requests to an API server. The API developer gave us the curl command, but I can't send it with Postman. How to make such a request?

curl -X POST "https://api-server.com/API/index.php/member/signin" -d "{"description":"","phone":"","lastname":"","app_version":"2.6.2","firstname":"","password":"my_pass","city":"","apikey":"213","lang":"fr","platform":"1","email":"[email protected]","pseudo":"example"}"

--0xKhTmLbOuNdArY
Content-Disposition: form-data; name="userfile"; filename="profil.jpg"
Content-Type: image/jpeg
Content-Transfer-Encoding: binary

<ffd8ffe0 00104a46 49460001 01010048 ... a00fffd9>

—0xKhTmLbOuNdArY—

5 comments

@Ankit Gupta 2019-03-29 06:30:49

sometimes whenever you copy cURL, it contains --compressed. Remove it while import->Paste Raw Text-->click on import. It will also solve the problem if you are getting the syntax error in postman while importing any cURL.

Generally, when people copy cURL from any proxy tools like Charles, it happens.

@Onkaar Singh 2016-05-06 09:32:05

A simpler approach would be:

  1. Open POSTMAN
  2. Click on "import" tab on the upper left side.
  3. Select the Raw Text option and paste your cURL command.
  4. Hit import and you will have the command in your Postman builder!

Hope this helps!

@austinthedeveloper 2016-05-25 19:30:33

I never knew you could do this until I saw this post. Thanks!

@Joshua Dance 2016-12-02 21:03:43

This is exactly what I wanted. Thanks!

@Rito 2017-06-21 08:48:09

I tried it and it worked partially. This is my curl request: curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d ' {"customer_id":"812122", "event":"add_to_cart", "email": "[email protected]", }' -u 9f4d7f5445e7: https://api.myapp.com/api/event After importing the body got imported correctly, the headers and the Url also got imported. Only the api key 9f4d7f5445e7 which is -u 9f4d7f5445e7: https://api.myapp.com/api/v1/event in the curl request did not import or may be Postman skipped it. Any idea how to resolve it?

@zhihong 2017-10-03 13:50:37

I figure it out to import curl cmd by myselft. But took me sometime to find out where is the page with my imported curl, it looks like nothing happen when import a file/cmd. You then need click on the "code" button on the top right side (under save button). Then you will see whether your curl is loaded or not.

@olisteadman 2019-02-27 11:16:06

This approach didn't utilise the credentials I coded into it, so had to add those manually using Auth > Basic Auth ,inside the actual request using mouse & dropdowns. Worth mentioning I think, since the software's behaviour is such that it appears to have accepted & utilised the creds:all you get is a "please supply valid credentials" rather than "please supply some credentials".

@Premraj 2019-04-23 14:13:39

@Onkaar can't we import other than cURL?

@electricalbah 2017-08-12 10:31:44

In addition to the answer
1. Open POSTMAN
2. Click on "import" tab on the upper left side.
3. Select the Raw Text option and paste your cURL command.
4. Hit import and you will have the command in your Postman builder!
5. If -u admin:admin are not imported, just go to the Authorization 
   tab, select Basic Auth -> enter the user name eg admin and password eg admin.
This will automatically generate Authorization header based on Base64 encoder

@Rito 2017-06-21 11:41:10

I tried the approach mentioned by Onkaar Singh,

  1. Open POSTMAN
  2. Click on "import" tab on the upper left side.
  3. Select the Raw Text option and paste your cURL command.
  4. Hit import and you will have the command in your Postman builder!

But the problem is it didn't work for the Apis which requires authorisation.

This was my curl request:

curl -v -H "Accept: application/json" -H "Content-type:
application/json" -X POST -d ' 
{"customer_id":"812122", "event":"add_to_cart", "email": "[email protected]", }' 
-u 9f4d7f5445e7: https://api.myapp.com/api/event

After importing the body got imported correctly, the headers and the Url also got imported. Only the api key 9f4d7f5445e7 which is

-u 9f4d7f5445e7: https://api.myapp.com/api/v1/event 

in the curl request did not import.

The way I solved it is, -u is basically used for Authorization. So while using it in Postman, you have to take the API key (which is 9f4d7f5445e7 in this case) and do Base64 Encode. Once encoded it will return the value OWY0ZDdmNTQ0NWU3. Then add a new header, the key name would be Authorization and key value would be Basic OWY0ZDdmNTQ0NWU3. After making that changes, the request worked for me.

There are online Base64 Encoders available, the one I used is http://www.url-encode-decode.com/base64-encode-decode/

Hope it helps!!!

@electricalbah 2017-08-12 10:28:12

on the authorization tab of postman just select Basic Auth and it will generate the Base64 header

@hello_harry 2015-09-02 18:19:46

1) Put https://api-server.com/API/index.php/member/signin in the url input box and choose POST from the dropdown

2) In Headers tab, enter:

Content-Type: image/jpeg

Content-Transfer-Encoding: binary

3) In Body tab, select the raw radio button and write:

{"description":"","phone":"","lastname":"","app_version":"2.6.2","firstname":"","password":"my_pass","city":"","apikey":"213","lang":"fr","platform":"1","email":"[email protected]","pseudo":"example"}

select form-data radio button and write:

key = name Value = userfile Select Text key = filename Select File and upload your profil.jpg

Related Questions

Sponsored Content

9 Answered Questions

[SOLVED] How to display request headers with command line curl

  • 2010-07-15 06:02:37
  • wwwxml
  • 409028 View
  • 470 Score
  • 9 Answer
  • Tags:   curl

20 Answered Questions

15 Answered Questions

[SOLVED] Using cURL with a username and password?

  • 2010-04-07 18:22:49
  • user246114
  • 616246 View
  • 390 Score
  • 15 Answer
  • Tags:   curl credentials

9 Answered Questions

[SOLVED] How to send a header using a HTTP request through a curl call?

  • 2008-12-10 16:38:57
  • gagneet
  • 1365808 View
  • 1234 Score
  • 9 Answer
  • Tags:   curl http-headers

21 Answered Questions

[SOLVED] How do I install and use curl on Windows?

7 Answered Questions

[SOLVED] Getting only response header from HTTP POST using curl

  • 2012-04-08 03:12:04
  • Jonathan Allard
  • 449981 View
  • 480 Score
  • 7 Answer
  • Tags:   post curl http-headers

4 Answered Questions

[SOLVED] PHP cURL custom headers

  • 2011-11-13 23:35:07
  • 123
  • 451926 View
  • 333 Score
  • 4 Answer
  • Tags:   php curl

14 Answered Questions

[SOLVED] How can I see the request headers made by curl when sending a request to the server?

  • 2009-05-15 04:10:50
  • leela
  • 381145 View
  • 434 Score
  • 14 Answer
  • Tags:   curl

1 Answered Questions

[SOLVED] How to convert cURL to postman?

  • 2017-03-28 10:57:23
  • James Chang
  • 25864 View
  • 32 Score
  • 1 Answer
  • Tags:   curl postman

0 Answered Questions

Sponsored Content