HTTP 406 Not Acceptable

The server cannot produce a representation matching your Accept header.

Defined in RFC 9110 §15.5.7 — 406 Not Acceptable · MDN reference

Where you meet HTTP 406 in production

Content negotiation that cannot be satisfied — a client asking for text/csv from an endpoint that only speaks JSON, or a version in an Accept header the server has retired.

Why you would test it

Worth provoking if your client sends a narrow Accept header, because the failure looks like a server fault and is actually a negotiation failure.

What your client should do about a 406

Do not retry with the same Accept header. Either fall back to a type the server does offer, or fail with a message naming what you asked for. A 406 that a client turns into "server error" wastes an on-call engineer's evening on a header.

406 versus the codes it gets confused with

Endpoints that return 406

2 endpoints in this playground answer with 406. Every one is free, needs no signup, and can be called from the browser or with curl.

Questions about HTTP 406

Is it better to return 406 or just ignore the Accept header?
Many APIs serve JSON regardless, which is pragmatic but hides a client bug. 406 is the honest answer.
Does Accept: */* ever produce a 406?
It should not — it means the client will take anything.

Other client error codes

All HTTP status codes · All 39 mock REST APIs · Getting started guide

Last updated