curl-example tagged requests and articles

Categorized request examples and articles tagged with [curl-example] keyword
Curl POST JSON Example
An example of a Curl command to post JSON to the API endpoint. To post JSON with Curl, you need to set the content type to application/json. This is done by the -H "Content-Type: application/json" command-line option. The JSON is passed with the curl -d option. Double quotes in JSON are escaped with \".

Curl GET JSON Example
An example of a Curl command to get JSON from the server. The Accept: application/json request header is passed to the server with the curl -H command-line option and tells the server that the client is expecting JSON. The server indicates that it has returned JSON data with a Content-Type: application/json response header.

Curl POST Form Example
An example of a Curl command to post a form in a URL-encoded format. The form data is passed as key/value pairs with -d curl command-line parameter. The Content-Type header application/x-www-form-urlencoded specifies the media type of the resource as urlencoded form data.

Curl POST XML Example
An example of a Curl command to post an XML string to the API endpoint. In this post XML request example, the 'Content-Type: application/xml' request header indicates that the request body contains an XML. The 'Accept: application/xml' request header tells the server that the client expects an XML. The XML is passed in the Curl -d command-line parameter.

Curl GET XML Example
An example of a Curl command to get and an XML data from the API endpoint. The Accept: application/xml request header tells the server that the client expects an XML response. The Content-Type: application/xml response header informs the client that the server returned an XML string.

Curl DELETE Request Example
An example of sending a DELETE request with Curl. In this Curl delete request example, the -X command-line option indicates the DELETE method, and the -H command-line option passes and custom HTTP header to the server.

Curl GET Example
An example of Curl GET request. In this Curl GET example, the HTTP GET method is specified with the -X GET command line parameter, and the target URL is passed as the last command line parameter. For this Curl GET example, the -X GET parameter is optional because Curl automatically selects the GET method unless the -X, --request, and -d command-line options are used.