Both HTTP 413 and HTTP 415 reject incoming HTTP request payloads, but for distinct reasons: quantity versus format.
Quantity vs. Format
- HTTP 413 Payload Too Large: Rejection is based on size. The request body contains too many bytes for the server or proxy buffer limits (e.g., exceeding
client_max_body_size). - HTTP 415 Unsupported Media Type: Rejection is based on format. Even if the payload is only 10 bytes, the server does not have a parser for the format declared in
Content-Type(e.g., sending XML to a JSON endpoint).
How to test with curl
curl -i -X POST https://api.example.test/v1/data \
-H "Content-Type: application/xml" \
-d '<item>test</item>'
Key takeaway
Use 413 Payload Too Large when the payload size exceeds buffer boundaries. Use 415 Unsupported Media Type when the payload format or MIME type is unrecognized by the endpoint.