Aarunya AppsAarunya Apps
415
Unsupported Media Type
Client Error

HTTP 415 Unsupported Media Type — Content-Type Validation

The server refuses to process the request because the media format indicated by the Content-Type header is not supported by the endpoint. The client should check the Accept or Accept-Post headers in the response.

When to Return 415

Return 415 when a client sends a Content-Type you don't support (e.g., text/plain when you only accept application/json), or when you receive multipart/form-data but only handle JSON.

Common Causes

  • Sending text/plain to an endpoint that requires application/json
  • Submitting an image in the wrong format (e.g., BMP when only JPEG/PNG are accepted)
  • Missing Content-Type header on a POST request
  • Wrong charset encoding (text/html instead of text/html; charset=utf-8)

HTTP Response Example

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

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

Code Examples

Express.js
const requireJson = (req, res, next) => {
  if (!req.is('application/json')) {
    return res.status(415).json({
      error: 'Unsupported Media Type',
      message: 'Content-Type must be application/json',
      accepted: ['application/json'],
    })
  }
  next()
}

app.post('/users', requireJson, createUser)
Next.js App Router
export async function POST(request: Request) {
  const contentType = request.headers.get('content-type') ?? ''
  if (!contentType.includes('application/json')) {
    return Response.json(
      { error: 'Unsupported Media Type', message: 'Expected application/json' },
      { status: 415, headers: { Accept: 'application/json' } }
    )
  }
  const body = await request.json()
  // proceed
}

Related Status Codes

All HTTP status codes

Browse the complete HTTP status code reference.

All Status Codes

Frequently Asked Questions

What does HTTP 415 Unsupported Media Type mean?

The server refuses to process the request because the media format indicated by the Content-Type header is not supported by the endpoint. The client should check the Accept or Accept-Post headers in the response.

When should an API return 415?

Return 415 when a client sends a Content-Type you don't support (e.g., text/plain when you only accept application/json), or when you receive multipart/form-data but only handle JSON.

What causes an HTTP 415 error?

Common causes: Sending text/plain to an endpoint that requires application/json; Submitting an image in the wrong format (e.g., BMP when only JPEG/PNG are accepted); Missing Content-Type header on a POST request; Wrong charset encoding (text/html instead of text/html; charset=utf-8).