HTTP 415 Unsupported Media Type — What It Means & How to Fix
HTTP 415 Unsupported Media Type is an HTTP response status code that indicates the server refuses to accept the request because the payload format is in an unsupported media type. The Content-Type header sent by the client does not match any format the endpoint is configured to accept.
What It Means
Defined in RFC 7231 Section 6.5.13, the 415 status code is the server’s way of saying: “I don’t understand this format. Send it in a format I support.” REST APIs commonly accept JSON (application/json) or form data (application/x-www-form-urlencoded), and returning 415 when receiving XML or plain text.
The server may include an Accept-Post or Accept-Patch header in the response indicating which media types are supported.
When It’s Sent
- Wrong Content-Type header — Sending
text/xmlwhen the API expectsapplication/json. - File upload with wrong MIME type — Uploading a
.txtfile when the endpoint expects.csv. - Legacy API versions — An old endpoint that only accepts XML receives JSON.
- Missing Content-Type header — The client sends the request without setting
Content-Type. - Binary vs text mismatch — Sending
application/octet-streamwhen the endpoint expectsmultipart/form-data.
Real Example
The following curl command sends a request with the wrong content type:
curl -X POST https://httpbin.org/post \
-H "Content-Type: text/plain" \
-d '{"key": "value"}' \
-w "\nHTTP Status: %{http_code}\n"Expected response:
HTTP/1.1 415 UNSUPPORTED MEDIA TYPE
Date: Sat, 20 Jun 2026 12:00:00 GMT
Content-Type: application/json
Content-Length: 101
{
"error": "Unsupported Media Type",
"message": "Content-Type 'text/plain' is not supported. Use application/json."
}How to Debug & Fix
Client-Side
- Set the correct Content-Type — Check API documentation and set
Content-Type: application/jsonfor JSON APIs. - Verify the request body format — Ensure the body matches the declared Content-Type. Sending XML with
Content-Type: application/jsonwill fail. - Use the right multipart encoding — For file uploads, use
Content-Type: multipart/form-datawith a boundary. - Check Accept header too — Some servers check both
Content-Type(what you send) andAccept(what you want back).
Server-Side
- List supported types in the response — Include an
Accept-Postheader listing accepted media types. - Support content negotiation — Implement proper content negotiation using the
Acceptheader. - Add a middleware check — Validate Content-Type early in the request pipeline before processing.
- Return a descriptive error — Tell the client exactly which media types are supported.
Common Causes Table
| Scenario | Likely Cause | How to Fix |
|---|---|---|
| API returns 415 for JSON | Endpoint expects application/json but client sends text/plain | Set Content-Type: application/json |
| File upload fails | MIME type mismatch between file and expected type | Validate the file extension and set proper MIME |
| Postman request fails | Default Content-Type in Postman is text/plain | Change to application/json in the Headers tab |
| Curl command fails | Curl does not set Content-Type by default | Add -H "Content-Type: application/json" |
| Legacy API migration | API upgraded from XML to JSON but client still sends XML | Update client to send JSON |
FAQ
Related Codes
HTTP 406 Not Acceptable — The server cannot produce a response in the client’s requested format.
HTTP 400 Bad Request — General client error for malformed requests.
HTTP 422 Unprocessable Entity — The format is correct but the content has semantic errors.
HTTP 501 Not Implemented — The server does not support the functionality needed.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro