Building an HTTP POST request using Curl and Postman

I use curl and Postman in Chrome to send POST HTTP requests from one variable to a simple HTTP server that I am running on, and I noticed that they build requests in a slightly different way. I apologize if I used any wrong terminology when constructing the question - I am still studying this material.

Using Postman, the query is built by putting '?' between the resource name and the variable. For instance.

http://192.168.0.2:9999/1/command?a=b 

However, the following curl command:

 curl -X POST http://192.168.0.2:9999/1/command --data a=b 

doesn't put a '?' between the resource name and the variable.

As a result, the HTTP server interprets requests differently.

In the first case, the request body is empty, and in the second case, the body contains a = b.

Which version is correct?

+5
source share
2 answers

POST requests mail data as part of the request body and GET requests through URL parameters. If you select the form data option in postman , you can pass it in the same way (request body) to postman . How are the parameters sent in the HTTP POST request? may be helpful.

+2
source

Building curl, python request using HTTP POST

  • Open the mail client and click on the code. [Below save button] see picture. Click save button

  • when you click on the code, another window appears. reference a snapshot change http post to curl

  • in the same way you can generate various other requests [curl, python, java, php] link to the snapshot

generate code snippets

You can link below at http://jmeterblogb.blogspot.in/2016/11/constructing-curl-from-python-http-php.html

+5
source

Source: https://habr.com/ru/post/1200594/


All Articles