Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

415 Unsupported Media Type

Server refuses request due to unsupported media type in Content-Type header.

When you see this status

  • Client sends JSON but sets Content-Type: text/plain
  • Client sends XML but sets Content-Type: application/json
  • Client omits Content-Type header entirely
  • Server expects multipart/form-data but receives application/json

Common causes

  • Missing or incorrect Content-Type header
  • Client sends data in unsupported format
  • Server misconfigured media type handling
  • Client sends empty body with non-empty Content-Type

How to debug it

  1. Verify Content-Type header matches actual payload format
  2. Check server-side media type parser configuration
  3. Inspect raw request headers and body
  4. Test with curl: curl -v -H 'Content-Type: application/json' ...

Return this code in your framework

Express (Node.js)
res.status(415).send('Unsupported Media Type');
FastAPI (Python)
from fastapi import HTTPException
raise HTTPException(status_code=415, detail="Unsupported Media Type")
NestJS
@Get() getData(@Body() data: any) {
  throw new UnsupportedMediaTypeException();
}
Go (net/http)
w.WriteHeader(http.StatusUnsupportedMediaType)
w.Write([]byte("Unsupported Media Type"))

About HTTP 415

HTTP status code 415 Unsupported Media Type is part of the 4xx Client Error family. Server refuses request due to unsupported media type in Content-Type header. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Can 415 occur if Content-Type is missing?

Yes, servers may treat missing Content-Type as unsupported media type depending on configuration.

How to fix 415 for file uploads?

Ensure Content-Type is set to multipart/form-data and boundary is included in header.

Does 415 require a response body?

No, but including details about supported media types improves client debugging.