Content-Type Header

The Content-Type HTTP header is used to indicate the type of media in the body of the message.

For example, when a file is sent to the server, the Content-Type header indicates the file format (for example, Content-Type: image/png). For JSON strings the Content-Type will be application/json, for XML strings the Content-Type will be application/xml, etc.

An example of an HTTP request sending JSON string to the server. The 'Content-Type: application/json' header tells the server that the request body contains a JSON string.

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

{"key": "value"}

When the server responds with a JSON string, it tells the client that the message body contains JSON string with 'Content-Type: application/json' header.

Server Response with Content-Type Header Live Request
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"success":"true"}

HTTP headers Content-Type requires certain directives such as Multipurpose Internet Mail Extensions (MIME) type of the data; Charset encoding standard in which the data will be received by the browsers; and the boundary directive when there are multipart entities that consist of 70 characters from a set of characters. These characters are known to be very robust through email gateways, and with no white space.

Possible values of HTTP Content-Type headers are listed below.

Application


  • application/EDI-X12
  • application/EDIFACT
  • application/javascript
  • application/octet-stream
  • application/ogg
  • application/pdf
  • application/xhtml+xml
  • application/x-shockwave-flash
  • application/json
  • application/ld+json
  • application/xml
  • application/zip
  • application/x-www-form-urlencoded

Audio


  • audio/mpeg
  • audio/x-ms-wma
  • audio/vnd.rn-realaudio
  • audio/x-wav

Image

  • image/gif
  • image/jpeg
  • image/png
  • image/tiff
  • image/vnd.microsoft.icon
  • image/x-icon
  • image/vnd.djvu
  • image/svg+xml

Multipart

  • multipart/mixed
  • multipart/alternative
  • multipart/related (using by MHTML (HTML mail).)
  • multipart/form-data

Text

  • text/css
  • text/csv
  • text/html
  • text/javascript (obsolete)
  • text/plain
  • text/xml

Video

  • video/mpeg
  • video/mp4
  • video/quicktime
  • video/x-ms-wmv
  • video/x-msvideo
  • video/x-flv
  • video/webm

VND

  • application/vnd.oasis.opendocument.text
  • application/vnd.oasis.opendocument.spreadsheet
  • application/vnd.oasis.opendocument.presentation
  • application/vnd.oasis.opendocument.graphics
  • application/vnd.ms-excel
  • application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
  • application/vnd.ms-powerpoint
  • application/vnd.openxmlformats-officedocument.presentationml.presentation
  • application/msword
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document
  • application/vnd.mozilla.xul+xml


Post HTTP Requests Online