415 Unsupported Media Type

Client Error - Server doesn't support this Content-Type

HTTP 415 Unsupported Media Type

What It Means

The HTTP 415 Unsupported Media Type status code indicates that the server refuses to accept the request because the payload format is not supported. The Content-Type header doesn't match what the server expects.

Common Causes

  • Missing Content-Type: No Content-Type header sent
  • Wrong Content-Type: Sent XML when JSON expected
  • Typo in header: "application/jason" instead of "application/json"
  • Missing charset: Some servers require charset=utf-8

Example

# Wrong Content-Type
POST /api/users HTTP/1.1
Content-Type: text/plain

{"name": "John"}

---

HTTP/1.1 415 Unsupported Media Type
Content-Type: application/json

{
  "error": "Unsupported Media Type",
  "message": "Expected application/json, got text/plain"
}

The Fix

# Correct request
POST /api/users HTTP/1.1
Content-Type: application/json

{"name": "John"}

---

HTTP/1.1 201 Created

Common Content-Types

Type Use For
application/json JSON APIs
application/x-www-form-urlencoded HTML form data
multipart/form-data File uploads
application/xml XML APIs

Server Implementation

// Express.js - validate Content-Type
app.use((req, res, next) => {
  if (['POST', 'PUT', 'PATCH'].includes(req.method)) {
    const contentType = req.get('Content-Type');
    if (!contentType?.includes('application/json')) {
      return res.status(415).json({
        error: 'Unsupported Media Type',
        message: 'Content-Type must be application/json'
      });
    }
  }
  next();
});

Client Examples

fetch

fetch('/api/users', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ name: 'John' })
});

curl

curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -d '{"name": "John"}'

Frequently Asked Questions

What does HTTP 415 Unsupported Media Type mean?
HTTP 415 Unsupported Media Type means the server refuses to accept the request because the Content-Type header does not match what the server expects. For example, sending text/plain when the API requires application/json will trigger this error.
How do I fix a 415 Unsupported Media Type error?
Set the correct Content-Type header in your request. For JSON APIs, use Content-Type: application/json. For form submissions, use application/x-www-form-urlencoded. For file uploads, use multipart/form-data. Check the API documentation for the expected content type.
What is the difference between 415 and 400?
415 Unsupported Media Type specifically means the Content-Type header is wrong or missing. 400 Bad Request means the request body is malformed or contains invalid syntax. If the JSON is valid but sent with Content-Type: text/plain, you get 415. If the Content-Type is correct but the JSON is malformed, you get 400.
What are the most common Content-Type values for APIs?
The most common are: application/json for JSON APIs, application/x-www-form-urlencoded for HTML form data, multipart/form-data for file uploads, application/xml for XML APIs, and text/plain for plain text. Most modern APIs use application/json.

Monitor your API endpoints

Track client errors across your services.

Start monitoring free →

Related Status Codes

More Resources