A media type (formerly MIME type) names a data format: application/json, text/csv, image/png, multipart/form-data. Content-Type states the media type of the body actually being sent; Accept states which media types the sender is willing to receive. Parameters refine it, as in text/csv; charset=utf-8.
Servers use the request's Content-Type to choose a parser and answer 415 Unsupported Media Type when they have none for it. Clients use the response's Content-Type to decide how to read the body. Structured suffixes such as application/problem+json signal "this is JSON with a known structure".
That the body speaks for itself. A JSON body sent as text/plain — a common default in some HTTP clients — will be refused or misread by a strict server, and a JSON response labelled text/html can be interpreted as a web page by a browser, which is a security problem as well as a bug.
The Movies poster upload answers 415 for a type it does not accept, and GET /protocol/v1/export/documents returns JSON, CSV or XML depending on Accept, answering 406 for anything else.
All glossary terms · Testing techniques · All 39 mock REST APIs
Last updated