406
HTTPERRORNotable4xx Client ErrorHIGH confidence

Not Acceptable

Production Risk

Low. This is a normal part of content negotiation. It typically affects API clients more than web browsers, which are usually more flexible with their 'Accept' headers.

What this means

This response is sent when the web server, after performing server-driven content negotiation, does not find any content that conforms to the criteria given by the user agent in the 'Accept' headers.

Why it happens
  1. 1A client requests JSON data (Accept: application/json) from an endpoint that can only serve XML.
  2. 2A browser requests a response in a language (Accept-Language: fr) that the server does not support.
  3. 3The client requests a specific character set (Accept-Charset) that is unavailable.
How to reproduce

A command-line tool requests a PNG image from a server that can only provide JPEG images.

trigger — this will error
trigger — this will error
GET /image HTTP/1.1
Host: example.com
Accept: image/png

expected output

HTTP/1.1 406 Not Acceptable

Fix 1

Adjust Client 'Accept' Headers

WHEN You control the client.

Adjust Client 'Accept' Headers
// Modify the request header
Accept: application/xml, application/json

Why this works

Client-Side Correction

Fix 2

Implement Content Transformation

WHEN You control the server.

Implement Content Transformation
// On the server, add support for JSON output
if (req.headers.accept === 'application/json') {
  // convert data to JSON and send
}

Why this works

Server-Side Logic

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All HTTP errors