Content Negotiation
A single resource can have several representations — JSON, CSV, different languages. Content negotiation lets the client state a preference and the server pick the best match, all without changing the URI.
How it works
Section titled “How it works”The client sends Accept (which media types it wants) and optionally Accept-Language; the server replies with the chosen representation and a matching Content-Type:
GET /reports/42 HTTP/1.1Accept: text/csv, application/json;q=0.8Accept-Language: th, en;q=0.5The q values are quality weights — here the client prefers CSV, then JSON. The server should honor the best type it supports and echo it in Content-Type.
When it cannot comply
Section titled “When it cannot comply”- If the server cannot produce any accepted type, respond
406 Not Acceptable. - If a request body arrives in a type the server cannot parse, respond
415 Unsupported Media Type.