Simulate a specific CURL in PostMan

I use Postman to check some Curl requests to the API server. The API developers gave us the curl command, but I cannot send it from the Postman. How to make such a request from a postman?

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@example.com ","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— 
+99
source share
5 answers

A simpler approach:

  • Open POSTMAN
  • Click the Import tab in the upper left.
  • Select the Raw Text option and paste the cURL command.
  • Hit the import, and you will have a team in your postmaster!

Hope this helps!

+271
source
 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 
+9
source

1) Put https://api-server.com/API/index.php/member/signin in the URL input field and select POST from the drop-down menu

2) On the "Headings" tab, enter:

Content-Type: image / jpeg

Content-Transfer-Encoding: Binary

3) On the "Body" tab, select the raw switch and write:

{"description":"","phone":"","lastname":"","app_version":"2.6.2","firstname":"","password":"my_pass","city":"","apikey":"213","lang":"fr","platform":"1","email":" email@example.com ","pseudo":"example"}

select the form-data radio button and write:

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

+4
source

I tried the approach mentioned by Onkaar Singh,

  • Open POSTMAN
  • Click the "Import" tab in the upper left.
  • Select the Raw Text option and paste the cURL command.
  • Hit the import, and you will have a team in your postmaster!

But the problem is that it does not work for Apis requiring authorization.

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": " abc@def.com ", }' -u 9f4d7f5445e7: https://api.myapp.com/api/event 

After importing the correct body import, headers and URLs were also imported. Only api key 9f4d7f5445e7 which

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

in a request for curls was not imported.

The way I solved this, -u is mainly used for authorization. Therefore, using it in Postman, you must take the API key (which in this case is 9f4d7f5445e7 ) and make Base64 Encode. After encoding, it will return the value OWY0ZDdmNTQ0NWU3 . Then add a new title, the key name will be Authorization , and the key value will be Basic OWY0ZDdmNTQ0NWU3 . After making these changes, the request worked for me.

Base64 online encoders are available, which I used http://www.url-encode-decode.com/base64-encode-decode/

Hope this helps !!!

+4
source

sometimes when you copy cURL it contains --compressed. Remove it while import-> Paste Raw Text -> clicks on import. This will also solve the problem if you get a syntax error in the postman when importing any cURL.

Usually, when people copy cURL from any proxy tools like Charles, this happens.

+1
source

Source: https://habr.com/ru/post/974022/


All Articles