Back to all status codes
415
Unsupported Media Type
The server refuses to accept the request because the media type is not supported.
Common Causes
- •Wrong Content-Type header
- •Unsupported file format
- •Missing Content-Type
Fix Solutions
Set correct Content-Type
Ensure Content-Type header matches the request body format.
Code Examples
// Express.js - Check content type
app.post('/api/data', (req, res) => {
if (req.headers['content-type'] !== 'application/json') {
return res.status(415).json({
error: 'Content-Type must be application/json'
});
}
// Process request...
});