406 Not Acceptable

Written by Evert Pot - - Aggregated on Tuesday January 8, 2019

Happy 2019! After a small hiatus we’re back with this captivating series. I hope you’re as excited as I am and I hope you have the best 2019!

406 Not Acceptable is emitted by a server when the client asked for a specific representation of a resource that the server doesn’t support.

Accept headers

HTTP has a feature called content negotation. This feature allows a client to request a specific version of a resource. These are the main relevant request headers:


This client is indicating that it prefers to receive application/json in French.

GET /foo HTTP/1.1
Accept: application/json
Accept-Language: fr-CA; q=1, fr; q=0.8 

If the server didn’t support JSON, it might respond with:

HTTP/1.1 406 Not Acceptable
Server: curveball/0.4
Content-Type: text/html

<h1>Je ne support pas application/json</h1>

Huge disclaimer: I only had 2 years of french and it’s over 15 years ago.


It’s a great idea for APIs to support this for the Accept/Content-Type header. If an API defines specific content-types, they might be easier to evolve. Strictly enforcing the appearance of an Accept header with these specific content-types really helps with this. If a client doesn’t send it, a 406 status should be returned.

Likewise, it can be useful for multi-lingual web applications to support Accept-Language to figure out the user’s preferred language.


« Ready-to-wear API Collections with … - Lorna Jane

Eric L. Barnes - Triggered »