ChatGPT解决这个技术问题 Extra ChatGPT

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):

https://i.stack.imgur.com/M1D5Y.png

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

https://i.stack.imgur.com/uwVrt.png

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

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
Is there a way to do this for Insomnia?
Here is a quick 2 min video guide youtu.be/L3m6cpQPsV0

J
Jose M. González

https://i.stack.imgur.com/ziTKS.png

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

https://i.stack.imgur.com/JKzG4.png

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


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.
I have searched almost everywhere for this and finally! your answer is to the point. Thanks a lot!
Honestly, super impressed with the Hooli, I mean Google, team for making postman portable to curl
A
Artem Bernatskyi

Starting from Postman 8 you need to visit here

https://i.stack.imgur.com/wX6ht.png


Thank you, I was confused where this button now at Postman 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
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
v
vivekagarwal277

https://i.stack.imgur.com/6Mld1.jpg


Thank you! Spent a good half hour trying to figure out where the "code" button had gone before seeing this answer.
T
TheFreddyKilo

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

https://i.stack.imgur.com/92rBv.png


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.
V
VeKe

Here is a quick video demonstration postman request to curl

Latest version 8.x:

Find Code symbol on the right side of the postman.

Select cURL from the dropdown.


D
Deepak Rajpal

https://i.stack.imgur.com/HXFxx.png

See screenshot: