415 Unsupported Media Type: How to Fix It on APIs, Forms, WordPress & NGINX

415 Unsupported Media Type means the server refused the request because it does not accept the request body’s format. The URL and method are fine. What doesn’t match what the endpoint expects is the Content-Type header, the Content-Encoding, the body itself, or the uploaded file type. In most cases you fix it on the client by sending the right header with a body that matches it.

Quick checks

  • Look at the exact request in DevTools → Network → the failed request → Headers → Content-Type.
  • For JSON, send Content-Type: application/json and a body that is valid JSON.
  • Check whether a Content-Encoding header (gzip and so on) is sent that the server doesn’t support.
  • For file uploads, check that the form uses enctype="multipart/form-data" and that the endpoint allows the file type.
  • Replay the request with curl (below). If curl works and your app doesn’t, the bug is in the client code.

What is 415 Unsupported Media Type?

415 is an HTTP client error. The server understood the request, but won’t process it because the body arrived in a format the resource doesn’t support. Similar codes mean different things:

  • 400 Bad Request: the request syntax or structure is invalid (for example malformed JSON).
  • 405 Method Not Allowed: the HTTP method isn’t allowed for the resource.
  • 406 Not Acceptable: about the response format the client asked for (Accept header).
  • 415 Unsupported Media Type: about the request body format the server received.

Causes and fixes

1. The Content-Type header is wrong

The body is JSON but the header says text/plain or application/x-www-form-urlencoded, or the body is form data sent as application/json. The server parses the body according to the header and rejects it.

How to check: Send the same body with an explicit header:

curl -i -X POST https://api.example.com/items \
  -H "Content-Type: application/json" \
  -d '{"name":"test"}'

This is the cause if curl returns 2xx while your client gets 415, and DevTools shows a different Content-Type on the failing request.

How to fix: Make the header match the body:

// JSON
fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(data)
});

// URL-encoded form
fetch(url, {
  method: "POST",
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
  body: new URLSearchParams(data)
});

2. The Content-Type header is missing

Custom fetch calls, backend scripts, webhooks and mobile apps often send a body without any content type. Many frameworks then reject it. Spring and ASP.NET return 415, and Express leaves req.body empty.

How to check: Print the headers that were actually sent:

curl -v -X POST https://api.example.com/items -d @body.json 2>&1 | grep -i '^> content-type'

This is the cause if there’s no Content-Type line, or curl -d silently set application/x-www-form-urlencoded.

How to fix: Always set the header explicitly in scripts and integrations:

curl -X POST https://api.example.com/items \
  -H "Content-Type: application/json" --data-binary @body.json

# Python requests: json= sets the header for you
requests.post(url, json=data)

3. The body format does not match the endpoint contract

The endpoint only accepts certain media types. For example, an API accepts JSON only and receives XML, or an upload route expects multipart and receives raw binary.

How to check: Read the API docs or the route definition, such as consumes or @Consumes in Spring or JAX-RS, the body parser in Express, or the accepts list in an OpenAPI spec. Some servers list the accepted types in an Accept-Post or Accept response header:

curl -i -X POST https://api.example.com/items -H "Content-Type: application/xml" -d '<a/>'

This is the cause if the type you send isn’t in the documented or accepted list.

How to fix: Send a format the endpoint accepts. If you own the server, enable the matching parser:

// Express
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

4. Content-Encoding is wrong or unsupported

The client declares Content-Encoding: gzip on a body that isn’t compressed, uses an encoding the server doesn’t support, or a proxy compresses the body without the backend expecting it.

How to check:

curl -v -X POST https://api.example.com/items \
  -H "Content-Type: application/json" -d '{"a":1}' 2>&1 | grep -i 'content-encoding'

This is the cause if the 415 disappears when you remove the Content-Encoding header or turn off request compression in the HTTP client or SDK.

How to fix: Don’t send Content-Encoding unless the server supports it. If you compress, really compress:

gzip -c body.json > body.json.gz
curl -X POST https://api.example.com/items \
  -H "Content-Type: application/json" -H "Content-Encoding: gzip" \
  --data-binary @body.json.gz

5. The uploaded file type is not allowed

The upload route exists, but it rejects the file’s MIME type. Sometimes the client sends a generic type such as application/octet-stream.

How to check:

file --mime-type photo.webp
curl -i -F "file=@photo.webp;type=image/webp" https://example.com/upload

This is the cause if a different file type (for example a JPEG) uploads fine on the same route, or the server logs name the rejected MIME type.

How to fix: Send the correct MIME type, or allow the type on the server. In WordPress, add it with the upload_mimes filter:

add_filter('upload_mimes', function ($m) {
    $m['webp'] = 'image/webp';
    return $m;
});

6. The HTML form uses the wrong enctype

A file upload form is missing multipart/form-data, or a JavaScript library overrides the browser’s default and posts JSON to a form handler.

How to check: Look at the <form> tag and, in DevTools, at the request’s Content-Type. Multipart requests show multipart/form-data; boundary=....

How to fix:

<form method="post" action="/upload" enctype="multipart/form-data">
  <input type="file" name="file">
</form>

When you send FormData with fetch, don’t set Content-Type yourself. The browser has to add the boundary:

const fd = new FormData(formEl);
fetch("/upload", { method: "POST", body: fd });   // no Content-Type header

7. The JavaScript or API client builds the request incorrectly

Common mistakes: the header is hardcoded wrong, the body is stringified twice, an object is passed without the right header, or the library adds a default type the backend rejects.

How to check: In DevTools → Network, right-click the request → Copy as cURL, then replay it. If the payload looks like "{\"name\":\"test\"}" (a quoted string), it was stringified twice.

How to fix: Stringify exactly once and set the header once. In Axios, pass the object as is (axios.post(url, data)), and Axios sends JSON with the right header. Remove global default headers that conflict with this request.

8. A reverse proxy, WAF or API gateway rejects or rewrites the request

The app supports the type, but something in front of it strips Content-Type, rewrites the body or allows only some media types. Examples are ModSecurity, Cloudflare WAF, API gateways and serverless adapters.

How to check: Send the same request directly to the app, bypassing the proxy:

curl -i -X POST http://127.0.0.1:3000/items \
  -H "Content-Type: application/json" -d '{"name":"test"}'
sudo grep -i "415\|ModSecurity" /var/log/nginx/error.log /var/log/apache2/error.log

This is the cause if the direct request works but the public one fails, or WAF or Cloudflare Security Events show a block on that URL.

How to fix: Make sure the proxy passes headers and the body unchanged. Nginx passes Content-Type by default, so remove any proxy_set_header Content-Type overrides. Allow the media type in the gateway’s content-type list. Add a WAF exception for the specific rule ID and path instead of turning off the WAF.

9. WordPress plugins or REST API rules reject the body

Security plugins, REST API restrictions, upload or media plugins, or optimization plugins change or block requests to /wp-json/ or admin-ajax.php.

How to check:

curl -i -X POST https://example.com/wp-json/wp/v2/posts \
  -u user:application-password \
  -H "Content-Type: application/json" -d '{"title":"test","status":"draft"}'

Then turn off plugins one by one (or all at once with wp plugin deactivate --all on staging) and retest. This is the cause if the 415 disappears when a specific plugin is off.

How to fix: Update or reconfigure that plugin, or add an allow rule for the REST route in it. If an upload type is rejected, add the MIME type as shown in cause 5.

General troubleshooting

  • Review recent changes first: API updates, frontend rewrites, new HTTP libraries, server config, plugin updates, WAF hardening, upload restrictions.
  • Check access logs, application logs and gateway logs together, and find the exact media type that was rejected.
  • Servers can be strict about syntax. Watch for an unexpected charset parameter, a typo in the subtype, or a missing multipart boundary.
  • Compare routes. A JSON route and an upload route, or a public and an admin API, often differ, and usually only one is misconfigured.
  • Don’t confuse 415 with 406. 415 is about the body you send, 406 about the Accept header for the response.

Prevention tips

  • Document required request formats for every API route.
  • Keep frontend and backend teams aligned on Content-Type expectations.
  • Test JSON, form, and upload requests after deployments.
  • Review file upload MIME restrictions before production use.
  • Be careful with proxy, WAF, and gateway layers that inspect request bodies.
  • Use consistent request-building code across apps and integrations.
  • Log rejected media types clearly on the server side.

When to contact support

  • Developer or API team: the endpoint contract is unclear, or the 415 started after a frontend or backend deployment.
  • Hosting provider or server admin: a reverse proxy or WAF may be involved, or uploads are filtered before they reach the app.
  • WordPress and plugins: it started after a plugin update, or only REST API, AJAX or upload requests fail.

FAQ

What does 415 Unsupported Media Type mean?

It means the server refused the request because the request body format is not supported for that resource.

How do I fix 415 Unsupported Media Type fast?

Check the exact Content-Type header, make sure it matches the body, confirm the endpoint accepts that format, and then review encoding, file type, proxies, security layers, and recent changes.

Can a wrong Content-Type cause a 415 error?

Yes. This is the most common cause. The body and the declared media type must match exactly.

Can file uploads cause 415 Unsupported Media Type?

Yes. If the file MIME type, form encoding, upload route, or security rules do not match what the server accepts, a 415 error can happen.

Can WordPress cause a 415 error?

Yes. WordPress plugins, REST API restrictions, upload settings, security plugins, and broken AJAX requests can all trigger 415 errors.

Related HTTP Errors

Leave a Comment