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.
GET /api/report HTTP/1.1
Host: api.example.com
Accept: application/xmlHTTP/1.1 406 Not Acceptable
Content-Type: application/json
{"error":"not_acceptable","supported":["application/json"]}app.get('/api/report', (req, res) => {
if (!req.accepts('json'))
return res.status(406).json({ supported: ['application/json'] });
res.json(report);
});