HTTP 415 Unsupported Media Type vs 421 Misdirected Request
Both HTTP 415 (Unsupported Media Type) and 421 (Misdirected Request) 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, 421 means that the request was directed at a server that is unable to produce a response for the combination of scheme and authority in the URI.
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 request was directed at a server that is unable to produce a response for the combination of scheme and authority in the URI.
When You See It
With HTTP/2 when a connection is reused for a domain the certificate doesn't cover.
How to Fix
Retry the request on a new connection.
Key Differences
HTTP 415: The server refuses to accept the request because the Content-Type is not supported.
HTTP 421: The request was directed at a server that is unable to produce a response for the combination of scheme and authority in the URI.
You encounter 415 when when sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
You encounter 421 when with HTTP/2 when a connection is reused for a domain the certificate doesn't cover.
When to Use Which
For 415 (Unsupported Media Type): Set the correct Content-Type header matching the data format you're sending. For 421 (Misdirected Request): Retry the request on a new connection.