# HTTP 415 Unsupported Media Type — Meaning, Causes & Fixes

> The server won't accept the format of the request body (its Content-Type).

415 is about what you sent, not what you want back: the request's `Content-Type` (or `Content-Encoding`) isn't one the endpoint accepts. The most common case is posting JSON without `Content-Type: application/json`, so the server reads the body as plain text or form data.

- Class: 4xx Client Error
- Retry: No — change the request first
- Cacheable by default: no
- Defined in: [RFC 9110 §15.5.16 — 415 Unsupported Media Type](https://www.rfc-editor.org/rfc/rfc9110.html#section-15.5.16)

## Example response

```http
HTTP/1.1 415 Unsupported Media Type
Content-Type: application/json
Content-Length: 34

{"error":"Unsupported Media Type"}
```

## Common causes

- No `Content-Type` on a JSON POST — `fetch()` labels string bodies `text/plain`.
- Sending form-urlencoded data to a JSON-only endpoint, or the reverse.
- Uploading a file type the endpoint rejects.
- A compressed body (`Content-Encoding: gzip`) the server can't decode.

## How to fix it

1. Set `Content-Type: application/json` when sending JSON.
2. Use the encoding the API documents: JSON, `multipart/form-data` or `x-www-form-urlencoded`.
3. On the server, list the supported types in an `Accept` or `Accept-Post` response header.

## Send a 415 from your server

### Express

```
res.status(415).json({ error: "Unsupported Media Type" });
```

### Next.js route handler

```
return Response.json({ error: "Unsupported Media Type" }, { status: 415 });
```

### Flask

```
return {"error": "Unsupported Media Type"}, 415
```

### Go net/http

```
http.Error(w, "Unsupported Media Type", http.StatusUnsupportedMediaType)
```

### nginx

```
return 415;
```

## FAQ

### Why does fetch() get 415 with a JSON body?

fetch(url, { method: 'POST', body: JSON.stringify(data) }) sends Content-Type: text/plain;charset=UTF-8. Add headers: { 'Content-Type': 'application/json' }.

### 415 vs 406?

415: the server can't accept the format you sent (Content-Type). 406: the server can't produce a format you'll accept (Accept).

## Related status codes

- [406 Not Acceptable](https://www.devkult.com/http/406.md)
- [400 Bad Request](https://www.devkult.com/http/400.md)
- [422 Unprocessable Content](https://www.devkult.com/http/422.md)

Open the interactive page: https://www.devkult.com/http/415