curl-json tagged requests and articles

Categorized request examples and articles tagged with [curl-json] keyword
How to post JSON using Curl?
To post JSON data using Curl, you need to set the Content-Type of your request to application/json and pass the JSON data with the -d command line parameter. The JSON content type is set using the -H "Content-Type: application/json" command line parameter. JSON data is passed as a string. Double quotes in JSON must be escaped with the backslash "\" on Windows computers. In this Curl POST JSON example, we send JSON to the ReqBin echo URL. Click Run to execute the Curl POST JSON example online and see result.

How do I get JSON with Curl?
To get JSON with Curl, you need to make an HTTP GET request and provide the Accept: application/json request header. The 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 in response. If you do not provide an Accept request header, the server may respond with a different MIME type than JSON. The server specifies the returned data type with the Content-Type response header. In this Curl GET JSON example, we send an HTTP GET request to download the JSON from the ReqBin echo URL. Click the Run button to execute the Curl GET JSON example online and see the results.

How do I send JSON data using Curl?
To send JSON data to the server using Curl, you need to pass the Content-Type: application/json HTTP header with the -H command line argument and the JSON data with the -d (or --data) command line argument. JSON data is passed as a string. You may also need to send the -H "Accept: application/json" HTTP header, which informs the server that the Curl client expects a JSON response. If you omit the Accept header, the server may respond with data of a different MIME type than JSON. The response Content-Type header specifies the type of data returned by the server. In this Curl POST JSON data example, we send JSON to the ReqBin echo URL. Click Run to execute the Curl JSON Request Example online and see the result.