AES Encryption Explained: How It Works and Why It Matters
Jun 23, 2026
4xx Client Error
The 406 (Not Acceptable) status code indicates that the target resource does not have a current representation that would be acceptable to the user agent, based on the proactive negotiation header fields received in the request (such as Accept, Accept-Language, or Accept-Encoding).
If your API supports only JSON responses but a client sends an Accept: application/xml header, return 406 Not Acceptable. The response should list the supported content types so the client can retry with an appropriate Accept header.
// Laravel - content negotiation with 406
if ($request->prefers('xml') && ! $request->expectsJson()) {
return response()->json([
'error' => 'XML not supported',
'supported_types' => ['application/json'],
], 406);
}
Mistake: Returning 406 when the Accept header is missing or wildcard
Fix: If the client sends Accept: */* or no Accept header, treat it as accepting any format and return the default (usually JSON). 406 is only appropriate when the client explicitly requests an unsupported format.
Blog
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026
Jun 23, 2026