How to POST data over http using curl

This article explains the details regarding curl command to POST data over http.

IF the POST request not requires any data, we can use the following command.

#curl -X POST url

Where url need to be replaced by the api for which the POST to be done.

If the POST request requires some data as argument, we can use the following command.

#curl -d "parameter1=value1&parameter2=value2" url

Where url need to be replaced by the api for which the POST to be done. Also the parameters and its values need to be updated accordingly.

If the POST required requires some JSON data, we can use the following command.

#curl -H "Content-Type: application/json" -X POST -d '{"parameter1":"value1","parameter2":"value2"}' url

Where url need to be replaced by the api for which the POST to be done. Also the parameters and its values need to be updated accordingly.

That's all…

Leave a Reply

Your email address will not be published. Required fields are marked *