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.
- No More postman just use cURL + vim =. Postman one of the most popular API client tool, for send and view the response in the development environment. But since Postman is proprietary software and there is a free + open sourced alternative so I'll go for something like insomnia, or postwoman.
- The method (GET,POST, PUT etc) is signified by -X in cURL, in PowerShell its -Method. In cURL we are adding the content type to the header, in PowerShell we specify the content with -ContentType. To bypass warning on insecure certificates on the URL we are working with use –insecure in cURL, in PowerShell 6.0 we use -SkipCertificateCheck.
- CURL – Post JSON data to Spring REST; Spring Boot file upload example – Ajax and REST; Tags: curl file upload json multipart post rest spring rest.
- Curl is a command-line tool for Linux, Windows, and macOS that can be used to send requests to the server. With Curl you can transfer files to or from the server, post forms and make your own curl requests with any headers and data. Generate Code Snippets for Convert Curl HTTP Request Example.
A reference guide to making GET, POST, PUT, PATCH, and DELETE API calls through the command line via cURL and their Postman equivalents.
Postman is an API testing environment. cURL is a command line tool for transfering data via URLs. When it comes to REST APIs, we can use Postman as a GUI (graphical user interface) and cURL as a CLI (command line interface) to do the same tasks.
Prerequisites
If you don't yet understand REST or know how to use REST APIs, please read Understanding REST and REST APIs.
Goals
I'm going to demonstrate how to do GET
, POST
, PUT
, PATCH
, and DELETE
requests via Postman and cURL. If you don't have Postman, simply download it from the website. cURL should already be installed in your macOS or Linux environment.
Endpoints
Postman Import Curl
I'm going to use JSON Placeholder, an awesome example site for testing API calls. You can follow along and paste all the commands into your terminal to see what response you get.
Here is the map of methods to endpoints we'll be using. /posts
means all, and the 1
in /posts/1
represents /posts/{id}
, so ID number1
.

Method | Endpoint |
---|---|
GET | https://jsonplaceholder.typicode.com/posts |
POST | https://jsonplaceholder.typicode.com/posts |
PUT | https://jsonplaceholder.typicode.com/posts/1 |
PATCH | https://jsonplaceholder.typicode.com/posts/1 |
DELETE | https://jsonplaceholder.typicode.com/posts/1 |
You can click those URLs to see the GET values they provide to the browser. You can use the browser for GET, but you'll have to use cURL or Postman to POST, PUT, PATCH or DELETE.
cURL CLI arguments
Here are a few cURL argument we'll pass with our requests. All requests will simply be curl
followed by the argument and data to pass.
-X --request
- Custom request method-d --data
- Sends the specified data-H --header
- Sends headers-i --include
- Display response headers
GET
GET retrieves data.
You can also use curl -i
to get more information from the headers.
All you have to do for Postman is paste the URL, select GET, and send.
POST
POST creates a new resource. It is non-idempotent, meaning that two identical POST requests will create two new resources.
There are two ways to do this via Postman. After selecting POST, you can go to Body, select x-www-form-urlencoded
, and type each individual value in. If you go to Headers, you'll see Content-Type: application/x-www-form-urlencoded
.
Or you can go to Body, select raw, select JSON
, and send the actual JSON you intend to send. If you go to Headers, you'll see Content-Type: application/json
.
PUT
PUT updates an existing resource. It is idempotent, meaning that two identical PUT requests will modify the same resource. A PUT request requires the entire body to be sent through; if any data is missing, that data will be wiped (except automatic values like auto-incrementing IDs and timestamps).
Sending the values is the same as with POST.
PATCH
PATCH updates an existing resource, and does not require sending the entire body with the request.
No change to sending the values.

DELETE
DELETE removes a resource.
No values to send.
Authentication
If you need to send additional headers, like Authorization: Bearer
or x-jwt-assertion
for JWT-based authentication, you can do it through cURL like this.
Curl To Postman Http
In Postman, you'll go to Headers and add Authorization
as the key and Bearer <JWT_TOKEN>
as the value to send authentication values. You can also go to Headers, click Presets, Manage Presets, and put your own reusable variables in for any headers or values you'll be reusing a lot.

Conclusion
Curl To Postman Converter
This guide provides all the basics for getting started with testing your APIs, either through Postman's GUI or cURL's CLI, using JSON or urlencoded form data.

Comments are closed.