Skip to content

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

  1. Set Content-Type to match the body, such as Content-Type: application/json.
  2. With fetch, add the header yourself: passing JSON.stringify output as the body sends it as text/plain.
  3. 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-Type
  • Content-Encoding
  • Accept-Encoding

Example response

HTTP/1.1 415 Unsupported Media Type
Content-Type: text/plain; charset=utf-8

415 Unsupported Media Type

How 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.

  • 406

    Not Acceptable

    The server cannot produce a response in any format the client said it accepts in its Accept headers.

  • 400

    Bad Request

    The server could not understand the request because something in it is malformed, like broken JSON, bad syntax or invalid headers.

  • 422

    Unprocessable Content

    The server understood the request and its format, but the data inside failed validation, like a missing field or bad email.

← all 63 HTTP status codes

Type to search posts, tools and projects.

Keyboard shortcuts

Search+Kor/
Go to homegthenh
Go to bloggthenb
Go to projectsgthenp
Go to timelinegthent
Show this help?
Close search or helpesc