In this recipe, we will discuss the cURL tool in Linux. The cURL tool is used for transferring the data from or to a server. It supports many protocols, and http
is one of them. cURL is used to transfer the data from URL. It has so many tricks to offer, such as http post, ftp post, user authentication, proxy support, file transfer, SSL connections, cookies, and similar.
Besides having a Terminal open, you need to ensure that you have curl
installed on your system.
We will learn about HTTP GET
and POST
methods using curl
in Linux. Now, we will see examples of GET
and POST
:
$ curl -H "Content-Type:application/json" -H "Accept:application/json" -X GET http://host/resource/name
Another example of HTTP GET, which is accepting XML formatted data is as follows:
$ curl -H "Content-Type:application...