415 Unsupported Media Type
The media format of the requested data is not supported by the server.
Usually happens because:
- ☑ Client sending XML data (Content-Type
- ☑ Uploading unsupported image formats (e.g.
🔍 Quick Checklist:
Meaning
The HTTP 415 Unsupported Media Type client error status code indicates that the origin server refuses to service the request because the payload is in a format not supported by this method on the target resource.
Root Causes
- Client sending XML data (Content-Type: application/xml) to an endpoint that only processes JSON.
- Uploading unsupported image formats (e.g. TIFF) to profile picture endpoints.
| Cause | Frequency |
|---|---|
| Client sending XML data (Content-Type | ⭐⭐⭐⭐⭐ |
| Uploading unsupported image formats (e.g. | ⭐⭐⭐⭐ |
Common Mistakes
- Sending HTTP requests with empty Content-Type headers when payload is present.
- Confusing 415 (payload sent is unsupported format) with 406 (format client requested in Accept header is unsupported).
How to Fix
Framework-Specific Examples
Express middleware validating Content-Type headers.
app.post('/api/data', (req, res) => {
if (req.headers['content-type'] !== 'application/json') {
return res.status(415).send('Unsupported Media Type: JSON only');
}
});Server Configuration Examples
Nginx handles format routing downstream to application.
# Format handled by upstream applicationsPrevention
- Explicitly declare Content-Type headers inside all client fetch utilities.
- Provide clear API documentation listing supported content types.
Frequently Asked Questions (FAQ)
Q: What is the difference between 406 and 415?
415 Unsupported Media Type means the *client uploaded* data in a format the server doesn't support. 406 Not Acceptable means the *client requested* the server to reply in a format the server doesn't support.
Q: Does 415 apply to file uploads?
Yes. If an endpoint expects a JPEG image but the client uploads a PDF, the server should reject the request with 415 Unsupported Media Type.
Q: Is 415 cacheable?
No. The 415 status code is not cacheable by default.
Q: How do clients resolve 415 errors?
Verify the request body structure, convert it to the expected format (e.g. serialize to JSON), and make sure the 'Content-Type' header matches.