MockFoxAdvertise

HTTP 415 Unsupported Media Type

Updated Free mock REST & WebSocket APIs

HTTP 415 Unsupported Media Type — The server refuses the request because the body's format (Content-Type) isn't supported.

Class
4xx Client Error
Defined in
RFC 9110 §15.5.16
Official
Yes (IANA registry)
Cacheable by default
No (unless Cache-Control/Expires say so)
Safe to retry
Not without changing the request

Try it: get a real 415 response

Our test endpoint answers every request with 415 Unsupported Media Type.

curl -i https://mockfox.dev/api/status/415

Use it in tests, health-check monitors or to see how your client handles a 415. Add ?delay=2000 to slow it down.

What does HTTP 415 mean?

415 Unsupported Media Type means the server refuses the request because the body is in a format the endpoint doesn't support. The server looks at the Content-Type (and sometimes Content-Encoding) header — or the data itself — and doesn't accept it.

The server may include an Accept header (for POST) or Accept-Patch header (for PATCH) listing the formats it does accept.

When is 415 used?

  • Sending JSON without Content-Type: application/json (e.g. as text/plain or form data).
  • Uploading a file type the endpoint doesn't accept (an image API receiving a PDF).
  • Using application/merge-patch+json where only application/json-patch+json is supported, or vice versa.
  • Sending a gzip-encoded body to a server that doesn't decode Content-Encoding: gzip.

Common causes of a 415

  • A missing or wrong Content-Type header — by far the most common cause.
  • fetch() sends a string body as text/plain;charset=UTF-8 unless you set the header.
  • ASP.NET Core and Spring return 415 when a [FromBody] / @RequestBody endpoint gets a content type it has no formatter for.

How to fix 415 Unsupported Media Type

If you're visiting the site

  1. Check that the file you're uploading is in a supported format (e.g. JPG/PNG instead of HEIC or WebP).
  2. Convert the file and try again.

If you run the site or API (developers)

  1. Set the right header: Content-Type: application/json for JSON, multipart/form-data for file uploads (let the browser set the boundary — don't set it manually with FormData).
  2. On the server, return 415 with an Accept header listing supported types.
  3. Use 400 for a body that claims to be JSON but isn't parseable; use 415 when the type itself is unsupported.

Returning or handling 415: server examples

fetch (client fix)

await fetch("/api/items", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ name: "Widget" }),
});

// File uploads: don't set Content-Type yourself
const form = new FormData();
form.append("file", file);
await fetch("/api/upload", { method: "POST", body: form });

Express

app.post("/api/items", (req, res, next) => {
  if (!req.is("application/json"))
    return res.status(415).set("Accept", "application/json").json({ error: "unsupported_media_type" });
  next();
}, createItem);

Next.js

// app/api/example/route.ts (Next.js App Router)
export async function POST(req: Request) {
  if (!req.headers.get("content-type")?.includes("application/json"))
    return Response.json({ error: "Send application/json" }, { status: 415, headers: { Accept: "application/json" } });
  const body = await req.json();
  // ...
}

Example 415 response

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

{"error":"unsupported_media_type","message":"Send the body as application/json"}

Related status codes

Related tools

Frequently asked questions

How do I fix 415 Unsupported Media Type in Postman?

In the Body tab choose raw → JSON (which sets Content-Type: application/json), or set the Content-Type header manually to what the API expects.

What's the difference between 415 and 406?

415 is about the format of what you send (Content-Type). 406 is about the format you ask to receive (Accept).

Why does my Spring or ASP.NET endpoint return 415?

The framework couldn't find a converter for the request's Content-Type — usually the header is missing or set to text/plain. Send application/json, or adjust the endpoint's consumes/Consumes attribute.