How to export Postman request as a cURL comman
https://help.mulesoft.com/s/article/How-to-export-Postman-request-as-a-cURL-command-to-help-MuleSoft-Support
How to export Postman request as a cURL command to help MuleSoft Support
How to export Postman request as a cURL command to help MuleSoft Support
GOAL
Export a postman request as a cURL command to help the support member with a standardized request.
PROCEDURE
In Postman, once you have your request configured. For example:Parameters
Headers
Body
This request is basic, you may have a complex request with more configurations and is the same process.
Click on the "Code" button
Postman will open a pop-up like this.
Change from HTTP to CURL
Share the CURL code to the support member.
Console output
Share the console output that has the complete request and response during execution.
Once a request has been sent, the Postman console records the header of request, variables, Response header and body, certificates, proxy settings, errors, scripts, output obtained from console.log, and so on.
=====================
https://stackoverflow.com/questions/49432735/converting-a-postman-request-to-curl
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):
And, here's how the contents inside the Headers(1)
tab look like:
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
-
1The 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– frz3993Mar 22, 2018 at 15:44
-
Is there a way to do this for Insomnia?– Anshuman KumarDec 16, 2020 at 11:18
-
Seems like all answers are correct answer just mentioning different version of UIs. :)– timDec 7, 2022 at 2:10
10 Answers
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
-
1Thanks. 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?– CoderMar 22, 2018 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. Jan 25, 2019 at 14:04
-
2Honestly, super impressed with the Hooli, I mean Google, team for making postman portable to curl Nov 15, 2019 at 20:29
-
8
-
only problem here is that the code panel was empty in my case in 8.0.4 - updating to 8.0.6 fixed this Feb 25, 2021 at 11:08
-
Can you write this as text for those of us who can't access Imgur on our work network? Jun 24, 2021 at 12:27
-
@user3067860 , this should help bernatskyys.s3.eu-west-1.amazonaws.com/… Jun 24, 2021 at 12:37
-
For those who use v7.36.5 for Ubuntu, or similar. Instead of the "</>" icon, there is a clickable "Code" text:
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.
-
4that is exatly the same solution than the other 7 post, what brings new ? Aug 19, 2022 at 12:42
-
Dear Ana, tried to be specific with the steps. Sorry if that seems redundant. Aug 22, 2022 at 2:19
If you're like me running MacOS and still have Postman v7, you have to click the ellipses here to find the code option
-
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.– ArlemiApr 7, 2021 at 9:39