Thursday, June 4, 2015

POST HTTP requests with cURL


To POST an HTTP request with cURL, run the command like this:
    curl -X POST -H "Content-Type:text/xml" --data @input-file --output output-file http://the-url
 
In this example, input-file is a text file with an XML request, and the content of the HTTP respone will be saved into output-file.

-H addes an HTTP header. In our example, we are sending an XML request so the Content-Type header is added to tell that.

For other options, refer to the online manpage in http://curl.haxx.se/docs/manpage.html.

cURL can be downloaded from http://curl.haxx.se/download.html. For Windows, there are some standalone versions that can run without installation, e.g. Win64-Generic: 7.33.0.


No comments:

 
Get This <