415 Unsupported Media Type
The server refuses the request body because its format, given by Content-Type or Content-Encoding, is not supported.
What 415 Unsupported Media Type means
The server checked the Content-Type or Content-Encoding of what you sent and does not handle it, for example XML sent to a JSON-only API.
415 is about the format of what you send. 406 is the reverse: the server cannot produce the format you asked to receive.
Common causes
- A missing Content-Type header, so the server cannot tell the body is JSON.
- Form data (application/x-www-form-urlencoded) sent to an endpoint expecting application/json, or the reverse.
- A compressed body (Content-Encoding: gzip) the server does not accept.
- Uploading a file type the endpoint does not allow.
How to fix 415 Unsupported Media Type
- Set Content-Type to match the body, such as Content-Type: application/json.
- With fetch, add the header yourself: passing JSON.stringify output as the body sends it as text/plain.
- Check the API docs for accepted formats. For compression problems, the server's Accept-Encoding response header lists what it supports.
Headers that go with it
Content-TypeContent-EncodingAccept-Encoding
Example response
HTTP/1.1 415 Unsupported Media Type
Content-Type: text/plain; charset=utf-8
415 Unsupported Media TypeHow to check for a 415 response
cURL
# Print only the status code
curl -s -o /dev/null -w "%{http_code}\n" https://example.com/JavaScript (Node.js)
const res = await fetch("https://example.com/");
if (res.status === 415) {
console.log(res.status, res.statusText);
}Python
import requests
res = requests.get("https://example.com/")
if res.status_code == 415:
print(res.status_code, res.reason)Go
res, err := http.Get("https://example.com/")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
if res.StatusCode == 415 {
fmt.Println(res.Status)
}Specification
415 Unsupported Media Type is defined in RFC 9110, section 15.5.16.
Related status codes
- 406
The server cannot produce a response in any format the client said it accepts in its Accept headers.
- 400
The server could not understand the request because something in it is malformed, like broken JSON, bad syntax or invalid headers.
- 422
The server understood the request and its format, but the data inside failed validation, like a missing field or bad email.