What 406 Not Acceptable means
406 Not Acceptable is content negotiation rejection. The client said Accept: application/xml but the server only produces JSON, so the server returns 406 rather than send the wrong format. In practice, 406 is rare; most servers default to JSON regardless of Accept headers, or return whatever they have. The response body should ideally include a list of acceptable representations the client could ask for instead.
When servers should return it: Return 406 only when you genuinely cannot produce any of the requested content types and you do not want to fall back to a default.
Common causes
- Accept header lists only types the server cannot produce
- Strict content-type negotiation enabled
- Client requested XML from a JSON-only API
How to fix 406 Not Acceptable
- Send
Accept: */*or omit the header to accept anything - Send
Accept: application/jsonfor most modern APIs - Check API docs for supported Content-Type values
Example response
curl -i -H "Accept: application/xml" https://api.example.com/users
HTTP/2 406
content-type: application/json
{"error":"only application/json supported"}
More references
For a one-page reference of all HTTP status codes, see the HTTP cheat sheet. For testing API responses, try the API Tester tool. For inspecting responses on the command line, the curl cheat sheet covers the most common flags.