Sending Client Request with Content-Type Header [Curl/Bash Code]

To send a Client request with a Content-Type header, you need to provide a Content-Type header in the "Name: value" format, just like you would for any standard HTTP header. The Content-Type HTTP header is used to indicate the type of media in the body of the message. In this Client Request with a Content-Type Header, we send a POST request to the ReqBin echo URL. Click Send to execute the Client Request with a Content-Type Header example online and see the results. The Curl/Bash code was automatically generated for the Client Request Content Type Header example.
Sending Client Request with Content-Type Header [Curl/Bash Code] Send
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Accept: application/json
Content-Type: application/json
Content-Length: 16

{"key": "value"}
Updated: Viewed: 19875 times
Curl/Bash code for Client Request Content Type Header example

Curl/Bash code for Client Request Content Type Header Example

This Curl/Bash code snippet was generated automatically for the Client Request Content Type Header example.
<< Back to the Client Request Content Type Header example

What is Content Type?

The Content-Type header determines the type of media the resource uses in an HTTP entity. A Content-Type is specified according to Multipurpose Email Extensions (MIME), which are standardized and published by the Internet Assigned Numbers Authority (IANA). A Content-Type header identifies the type, subtype, and optional parameters of the data in the body of an HTTP message.

Content-Type Example
Content-Type: image/png
Content-Type: text/html; charset=UTF-8
Content-Type: multipart/form-data;

What is MIME Type?

MIME (Multipurpose Internet Mail Extensions) is fundamental to communication protocols such as HTTP. Setting the correct MIME data type in the body of the message is critical for both HTTP requests and responses and allows you to control how the client and server interpret the request. Web servers and browsers have a list of well-known file extensions and MIME types. This helps them identify and decrypt all known file types, regardless of the operating system and hardware used by the user.

Client Request with Content-Type Header Example

The following is an example of an HTTP request to send a JSON string to the server. The "Content-Type: application/json" header tells the server that the request body contains a JSON string:

Sending Request with Content-Type Header Example
POST /echo/post/json HTTP/1.1
Host: reqbin.com
Accept: application/json
Content-Type: application/json
Content-Length: 16

{"key": "value"}

Server response to our Request with Content-Type Header:

Server Response Example
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"success":"true"}

See also

Generate code snippets for Curl/Bash and other programming languages

Convert your Client Request Content Type Header request to the PHP, JavaScript/AJAX, Node.js, Curl/Bash, Python, Java, C#/.NET code snippets using the Curl/Bash code generator.