406

Not Acceptable

Overview

406 Not Acceptable is returned when the server cannot produce a response in a format required by the request's Accept-family headers — that is, content negotiation failed.

For example, if the client allowed only Accept: application/xml but the server can only produce JSON, no representation satisfies the constraint, so it responds 406.

When it happens

Request / Response example

Request
GET /api/report HTTP/1.1
Host: api.example.com
Accept: application/xml
Response
HTTP/1.1 406 Not Acceptable
Content-Type: application/json

{"error":"not_acceptable","supported":["application/json"]}

In code

app.get('/api/report', (req, res) => {
  if (!req.accepts('json'))
    return res.status(406).json({ supported: ['application/json'] });
  res.json(report);
});

Common causes

How to fix

Notes

Related status codes

Related headers

Specification