HTTP 401 Unauthorized vs 415 Unsupported Media Type
Both HTTP 401 (Unauthorized) and 415 (Unsupported Media Type) belong to the 4xx Client Error category. 401 indicates that the request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme. Meanwhile, 415 means that the server refuses to accept the request because the Content-Type is not supported.
Description
The request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme.
When You See It
When accessing a protected resource without credentials or with expired tokens.
How to Fix
Include valid authentication credentials (API key, Bearer token, Basic auth) in the Authorization header.
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.
Key Differences
HTTP 401: The request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme.
HTTP 415: The server refuses to accept the request because the Content-Type is not supported.
You encounter 401 when when accessing a protected resource without credentials or with expired tokens.
You encounter 415 when when sending JSON to an endpoint that only accepts XML, or missing the Content-Type header.
When to Use Which
For 401 (Unauthorized): Include valid authentication credentials (API key, Bearer token, Basic auth) in the Authorization header. For 415 (Unsupported Media Type): Set the correct Content-Type header matching the data format you're sending.