Content Negotiation Errors — Accept Header and 406 Not Acceptable Responses
Informational4xx client error
Overview
Fix HTTP content negotiation errors where servers return 406 Not Acceptable or wrong content formats due to Accept header mismatches.
Key Details
- Content negotiation allows clients to specify preferred response formats using Accept headers
- Accept: application/json requests JSON; Accept: text/html requests HTML; Accept: */* accepts any format
- 406 Not Acceptable is returned when the server cannot produce a response matching the Accept header
- Quality values (q=0.9) indicate preference order: Accept: application/json;q=1, text/html;q=0.5
- Content-Type in the response indicates which format was chosen by the server
Common Causes
- Client sending Accept: application/json to an endpoint that only returns HTML
- Server strictly enforcing Accept headers instead of falling back to a default format
- Accept header malformed — missing commas between media types or invalid quality values
- API documentation specifying a different Accept header than what the server actually expects
Steps
- 1Set the correct Accept header for the expected response format: application/json for REST APIs, text/html for web pages
- 2Use Accept: */* or omit the Accept header to accept any format the server provides
- 3Implement server-side fallback: if no Accept header matches, return the default format instead of 406
- 4Check the Content-Type of the response to verify which format was selected
- 5Test content negotiation: 'curl -H "Accept: application/json" https://api.example.com/resource'
Tags
content-negotiationaccept406media-typeformat
More in 4xx Client Error
http-400-bad-requestHTTP 400 Bad Request — What It Means & How to Fix It
Errorhttp-401-unauthorizedHTTP 401 Unauthorized — What It Means & How to Fix It
Errorhttp-402-payment-requiredHTTP 402 Payment Required — What It Means & How to Fix It
Errorhttp-403-forbiddenHTTP 403 Forbidden — What It Means & How to Fix It
Errorhttp-404-not-foundHTTP 404 Not Found — What It Means & How to Fix It
Errorhttp-405-method-not-allowedHTTP 405 Method Not Allowed — What It Means & How to Fix It
ErrorFrequently Asked Questions
The server cannot produce a response in any format acceptable to the client based on the Accept header. Either the client needs to accept additional formats or the server needs to support the requested format.