430

I am calling my java webservice (POST request) via POSTMAN in the following manner which works perfectly fine (i.e. I can see my records getting inserted into the database):

enter image description here

And, here's how the contents inside the Headers(1) tab looks like:

enter image description here

Instead of calling it via POSTMAN, I have to call the same request in PHP using CURL. I am wondering if there's a way to export this command to curl command so that I could use it in my PHP code? I have found opposite approach at many places online where someone is asking to convert Curl based request to POSTMAN but couldn't figure out how to do the opposite.

Some articles I found for curl to postman

Sebastian Simon
  • 16,564
  • 7
  • 51
  • 69
Coder
  • 4,431
  • 2
  • 8
  • 10
  • 1
    The last time I used Postman I remember it showed the curl command for cli somewhere. Regardless, using phpcurl to post a json body is quite straightforward. The json string as the postfield and set the appropriate header – frz3993 Mar 22 '18 at 15:44
  • Is there a way to do this for Insomnia? – Anshuman Kumar Dec 16 '20 at 11:18
  • Here is a quick 2 min video guide https://youtu.be/L3m6cpQPsV0 – VeKe Aug 22 '21 at 08:36

6 Answers6

847

Open code window

You can see the button "Code" in the attached screenshot, press it and you can get your code in many different languages including PHP cURL

Code snippets window

Edited: As other answers said Postman UI was updated, I change the images accordingly

Jose M. González
  • 9,000
  • 1
  • 12
  • 9
  • 1
    Thanks. I found similar thread here : https://stackoverflow.com/questions/40632296/how-can-i-convert-data-from-postman-into-php-curl-request . But it's showing lot of things like Postman-Token, Cache-Control. Do I need to include that? – Coder Mar 22 '18 at 16:16
  • Gracias Jose, this is amazing. @Coder no you don't need the Postman-Token and the Cache-Control header depends if you want to prevent cashing of the req or not. If you want always fresh content, include it. – Lukas Lukac Jan 25 '19 at 14:04
  • I have searched almost everywhere for this and finally! your answer is to the point. Thanks a lot! – scipsycho Mar 29 '19 at 15:08
  • 2
    Honestly, super impressed with the Hooli, I mean Google, team for making postman portable to curl – GavinBelson Nov 15 '19 at 20:29
137

Starting from Postman 8 you need to visit here

enter image description here

Artem Bernatskyi
  • 3,350
  • 2
  • 23
  • 29
29

The first answer here works with the older versions of Postman. With the latest releases in 2021 the cURL can be found clicking this icon (circled in red) enter image description here

vivekagarwal277
  • 451
  • 5
  • 3
  • 1
    Thank you! Spent a good half hour trying to figure out where the "code" button had gone before seeing this answer. – Adam Parkin Jul 28 '21 at 00:38
9

If you're like me running MacOS and still have Postman v7, you have to click the ellipses here to find the code option

TheFreddyKilo
  • 399
  • 3
  • 10
  • This ellipsis show only when you're using the side-by-side view and when the screen resolution doesn't allow for all the tabs to be shown at the same time. You can change the display at the bottom-right of the window. – Arlemi Apr 07 '21 at 09:39
7

Here is a quick video demonstration postman request to curl

Latest version 8.x:

  • Find Code symbol on the right side of the postman. enter image description here

  • Select cURL from the dropdown. enter image description here

VeKe
  • 9,043
  • 5
  • 61
  • 67
4

enter image description hereTo extend the existing answers, there is an option to generate PHP ready cURL code if needed. With latest Postman, you will find dropdown for PHP - cURL and other languages.

See screenshot:

Deepak Rajpal
  • 637
  • 1
  • 6
  • 11