HTTP 415 Unsupported Media Type vs 431 Request Header Fields Too Large
Both HTTP 415 (Unsupported Media Type) and 431 (Request Header Fields Too Large) belong to the 4xx Client Error category. 415 indicates that the server refuses to accept the request because the Content-Type is not supported. Meanwhile, 431 means that the server refuses to process the request because an individual header field or all headers collectively are too large.
Description
The server refuses to accept the request because the Content-Type is not supported.
When You See It
When sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
How to Fix
Set the correct Content-Type header matching the data format you're sending.
Description
The server refuses to process the request because an individual header field or all headers collectively are too large.
When You See It
When cookies accumulate to an excessive size, or a single header (like Authorization) is too long.
How to Fix
Reduce header sizes. Clear excessive cookies. Use shorter tokens.
Key Differences
HTTP 415: The server refuses to accept the request because the Content-Type is not supported.
HTTP 431: The server refuses to process the request because an individual header field or all headers collectively are too large.
You encounter 415 when when sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
You encounter 431 when when cookies accumulate to an excessive size, or a single header (like Authorization) is too long.
When to Use Which
For 415 (Unsupported Media Type): Set the correct Content-Type header matching the data format you're sending. For 431 (Request Header Fields Too Large): Reduce header sizes. Clear excessive cookies. Use shorter tokens.