789

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

3
  • 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 Commented Mar 22, 2018 at 15:44
  • Is there a way to do this for Insomnia? Commented Dec 16, 2020 at 11:18
  • 2
    Seems like all answers are correct answer just mentioning different version of UIs. :) Commented Dec 7, 2022 at 2:10

10 Answers 10

1519

Open code window

You can see the button </> Code icon in right side of the Postman app (attached screenshot).
Press it and you can get your code in many different languages including PHP cURL

Code snippets window

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks. I found similar thread here : stackoverflow.com/questions/40632296/… . But it's showing lot of things like Postman-Token, Cache-Control. Do I need to include that?
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.
Honestly, super impressed with the Hooli, I mean Google, team for making postman portable to curl
ugh, mine isn't including any of the headers generated by authentication.
206

Starting from Postman 8 you need to visit here

enter image description here

5 Comments

only problem here is that the code panel was empty in my case in 8.0.4 - updating to 8.0.6 fixed this
Can you write this as text for those of us who can't access Imgur on our work network?
@user3067860 , this should help bernatskyys.s3.eu-west-1.amazonaws.com/…
I hate this new UI, it takes up so much more memory on windows as well
To the user above, the button on the top right has a symbol that looks like: </>
38

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

Comments

17

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

Comments

14

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

Comments

10

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.

2 Comments

that is exatly the same solution than the other 7 post, what brings new ?
Dear Ana, tried to be specific with the steps. Sorry if that seems redundant.
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

1 Comment

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.
5

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:

Comments

5

Select </> Code icon from right side in Postman.

Comments

2

For Postman Version 7.36.5 (7.36.5)

enter image description here

1 Comment

What about Postman 7.36.4?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.