625

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 look 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 a curl command so that I could use it in my PHP code? I have found the opposite approach at many places online where someone is asking to convert a curl based request to Postman but couldn't figure out how to do the opposite.

I found this question for curl to Postman: Simulate a specific CURL in PostMan

Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
Coder
  • 6,381
  • 2
  • 9
  • 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 – VedantK Aug 22 '21 at 08:36
  • Seems like all answers are correct answer just mentioning different version of UIs. :) – tim Dec 07 '22 at 02:10

10 Answers10

1205

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

Boris Verkhovskiy
  • 14,854
  • 11
  • 100
  • 103
Jose M. González
  • 12,590
  • 1
  • 13
  • 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
  • 2
    Honestly, super impressed with the Hooli, I mean Google, team for making postman portable to curl – GavinBelson Nov 15 '19 at 20:29
180

Starting from Postman 8 you need to visit here

enter image description here

Artem Bernatskyi
  • 4,185
  • 2
  • 26
  • 35
31

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
  • 505
  • 5
  • 5
11

For those who use v7.36.5 for Ubuntu, or similar. Instead of the "</>" icon, there is a clickable "Code" text:

enter image description here

iloo
  • 926
  • 12
  • 26
9

Steps:

  • Open Postman
  • Open your request
  • Select </> icon from right side bar
  • Select cURL from dropdown (if not cURL is there by default)
  • Copy the code and use.
8

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
  • 417
  • 5
  • 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
6

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

VedantK
  • 9,728
  • 7
  • 66
  • 71
4

Select </> icon from right side bar work so fine for me in Postman here.

Hadesh
  • 49
  • 2
3

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
  • 811
  • 1
  • 8
  • 11
0

For Postman Version 7.36.5 (7.36.5)

enter image description here

Jai Kumaresh
  • 715
  • 1
  • 7
  • 33