The 406 Not Acceptable HTTP status code indicates that the server cannot generate a response that matches the list of acceptable values defined in the request’s headers, most commonly the Accept header.
Accept, Accept-Language, or Accept-Encoding headersHTTP uses content negotiation to decide which representation of a resource should be sent to the client. If the client explicitly requests formats the server cannot provide, the server responds with 406.
// Client requests only XML, server supports JSON
GET /api/users HTTP/1.1
Host: example.com
Accept: application/xml
The server checks the Accept header and finds no compatible response format. As a result, it returns:
// Server response indicating unacceptable format
HTTP/1.1 406 Not Acceptable
Content-Type: text/plain
Requested format is not supported.
Use the simulator below to mimic a client request. The server only supports application/json.
// JavaScript fetch with restrictive Accept header
fetch("/api/data", {
headers: {
Accept: "application/xml"
}
});
Accept-LanguageAccept-EncodingAccept header validationAccept headers and observe responses