You're integrating with a new API. You carefully craft a JSON request with all the right data, send it off, and instead of the success response you expected, you get back a frustrating error: 415 Unsupported Media Type
. You double-check your authentication, your endpoint URL, your data payload everything seems correct. So what went wrong?
The problem likely isn't with what you sent, but with how you told the server what you were sending. This common but often confusing status code is all about communication breakdowns in data format.
The 415
error is the server's way of saying, "I understand you're trying to send me data, but I don't speak this language. I was expecting you to send it in a different format that I can actually process."
If you're a developer working with APIs whether building them or consuming them understanding the 415
status code is crucial for smooth integrations and avoiding frustrating debugging sessions.
In this detailed guide, we’ll explore what the 415 Unsupported Media Type status code means, why it happens, typical scenarios, and practical ways to fix or avoid it. Whether you’re a developer dealing with API integrations or curious about how web communication works, this post will help you master 415 errors.
Alright, let’s jump in and clear the confusion around HTTP 415 once and for all.
The Problem: Speaking the Server's Language
Imagine you're mailing a letter to someone who only reads French. You could write the most eloquent, perfectly structured English letter, but if the recipient doesn't understand English, your message will be useless. The 415
error is the digital equivalent of this scenario.
Web servers are often built to understand specific data formats. They need to know what "language" the incoming data is written in so they can properly parse and process it. The Content-Type
header is how the client tells the server what format the data is in.
What Does HTTP 415 Unsupported Media Type Actually Mean?
The 415 Unsupported Media Type
status code indicates that the server understands the request, but it refuses to accept it because the payload format (media type) is in a format not supported by the server for the requested resource.
In simpler terms, your client (like Postman, Apidog, or your browser) is sending data in a format that the server doesn’t understand or is not configured to process.
The server is essentially saying: "I received your data, but I cannot process it because it's in a format I don't understand or support for this particular endpoint."
A typical 415
response looks like this:
HTTP/1.1 415 Unsupported Media TypeContent-Type: application/json
{
"error": "Unsupported Media Type",
"message": "The request payload format is not supported.",
"supported_types": ["application/json", "application/xml"]
}
This tells you, “Hey! I got your request, but I can’t process this content type.”
This most commonly relates to the value of the Content-Type
header in the HTTP request specifying the format of the data being sent (like JSON, XML, or multipart form data). Some servers might provide more helpful information about what formats they do support, while others might return a more generic error message.
Deep Dive: The Technical Definition (for the Curious)
According to the HTTP/1.1 specification (RFC 7231), Section 6.5.13 defines the 415 status code as:
“The 415 (Unsupported Media Type) status code indicates that the origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource.”
The key point here:
- The issue lies in the media type, not the data itself.
- The server knows what you’re trying to send it just can’t process it.
The Heart of the Matter: The Content-Type Header
The Content-Type
header is the crucial piece of information that determines whether you'll get a 415
error or a successful response. This header tells the server what kind of data you're sending in the request body.
Here are the most common content types you'll encounter:
Common Content-Type Values:
For JSON APIs:
application/json
- The standard for most modern REST APIsapplication/json; charset=utf-8
- JSON with explicit character encoding
For Form Data:
application/x-www-form-urlencoded
- Traditional HTML form submission formatmultipart/form-data
- Used for file uploads and forms with files
For XML:
application/xml
- Standard XML formattext/xml
- Alternative XML format
For Plain Text:
text/plain
- Simple text contenttext/html
- HTML content
How the 415 Error Occurs: A Step-by-Step Breakdown
Let's walk through exactly what happens when a 415
error occurs.
Step 1: The Client Sends a Request
A client application sends a request to a server API endpoint. For example, let's say we're trying to create a new user:
POST /api/users HTTP/1.1Host: api.example.comContent-Type: application/xmlContent-Length: 125
<user><name>John Doe</name><email>john@example.com</email></user>
Step 2: The Server Checks the Content-Type
The server receives the request and examines the Content-Type
header. It sees application/xml
and checks its configuration for the /api/users
endpoint.
Step 3: The Server Realizes the Problem
The server's /api/users
endpoint is configured to only accept application/json
. It doesn't have an XML parser set up for this endpoint, and it doesn't know how to handle the incoming data.
Step 4: The 415 Response
Instead of trying to process the malformed data (which could lead to errors or security issues), the server responds with a 415 Unsupported Media Type
status code.
Step 5: The Client Receives the Error
The client application receives the 415
response and needs to handle it appropriately usually by correcting the Content-Type
header and resending the request.
Common Scenarios Where You Might Encounter 415
1. Uploading Files in APIs
If you try to upload an image using application/json
instead of multipart/form-data
, the server won’t understand the file content.
2. Custom APIs With Strict Validation
APIs with strict schema validation reject any request that doesn’t match their rules.
3. Mobile Apps Using Outdated SDKs
Sometimes older SDKs send requests with outdated headers, which modern APIs no longer support.
4. Cross-Origin Requests (CORS Issues)
Certain CORS configurations may restrict accepted content types, indirectly causing a 415 response.
The Role of Content-Type Header
The Content-Type
header in HTTP requests tells the server what type of data the client is sending.
For example:
application/json
for JSON payloads.text/xml
for XML data.multipart/form-data
for file uploads.
If this header is missing or says something the server can’t handle, you’ll likely see a 415 response.
Real-World Scenarios That Cause 415 Errors
Scenario 1: Missing Content-Type Header
POST /api/users HTTP/1.1Host: api.example.com
{"name": "John Doe", "email": "john@example.com"}
Many servers will reject this because there's no Content-Type
header telling them how to interpret the data.
Scenario 2: Wrong Content-Type for the Data
POST /api/users HTTP/1.1Host: api.example.comContent-Type: application/x-www-form-urlencoded
{"name": "John Doe", "email": "john@example.com"}
The header says it's form data, but the body is JSON. This mismatch confuses the server.
Scenario 3: Server Doesn't Support the Format
POST /api/users HTTP/1.1Host: api.example.comContent-Type: application/xml
<user><name>John</name></user>
The server might only support JSON for this endpoint, even though the XML is well-formed.
Testing Content-Type Handling with Apidog

Let’s talk about how Apidog can make your life easier when dealing with these errors. Testing different content types and ensuring your API handles them correctly is where Apidog shines. It makes it incredibly easy to test these scenarios without writing complex code.
With Apidog, you can:
- Easily Set Content-Type Headers: Use Apidog's intuitive interface to select from common content types or specify custom ones.
- Test Multiple Formats: Quickly test the same endpoint with different content types (JSON, XML, form data) to see how your server responds.
- Validate Error Responses: Ensure your API returns proper
415
responses with helpful error messages when receiving unsupported formats. - Test Edge Cases: Experiment with malformed content types, missing headers, or mismatched data to ensure your API handles them gracefully.
- Automate Content-Type Testing: Create test suites that automatically verify your API correctly accepts supported formats and properly rejects unsupported ones.
For example, when you set up a POST request in Apidog, it automatically applies the correct Content-Type
based on your request body type (JSON, XML, form-data, etc.).
That means fewer surprises and no more 415 errors ruining your test sessions. This proactive testing can save hours of debugging and ensure your API behaves predictably.
415 vs. Other 4xx Errors: Knowing the Difference
It's important to distinguish 415
from other client errors:
400 Bad Request
: The request is malformed or has syntax errors, regardless of content type.415 Unsupported Media Type
: The request is well-formed, but in a format the server doesn't support for this endpoint.406 Not Acceptable
: The opposite of415
the client cannot accept the response format the server wants to send.
Best Practices for Handling 415 Errors
For API Consumers (Client Developers):
- Always set the correct Content-Type header that matches your request body format.
- Check API documentation to see what media types are supported for each endpoint.
- Handle 415 errors gracefully in your code don't assume the server will accept any format you send.
- Provide fallback behavior if possible, such as converting your data to a supported format.
For API Providers (Server Developers):
- Be explicit about supported media types in your API documentation.
- Return helpful error messages that indicate what media types you do support.
- Consider supporting multiple formats if it makes sense for your API (e.g., both JSON and XML).
- Use proper HTTP status codes don't use
400
when you mean415
.
Example of a Well-Designed 415 Response:
HTTP/1.1 415 Unsupported Media TypeContent-Type: application/json
{
"error": "unsupported_media_type",
"message": "This endpoint only accepts application/json payloads.",
"supported_types": ["application/json"],
"documentation": "<https://api.example.com/docs/content-types>"
}
Common Content-Type Mistakes That Cause 415
Here are some pitfalls developers frequently fall into:
Mistake | Description | Example |
---|---|---|
Using wrong header name | Typo or casing issue | contenttype instead of Content-Type |
Sending form data instead of JSON | Server expects JSON only | application/x-www-form-urlencoded |
Forgetting charset | Missing encoding info | application/json; charset=utf-8 |
Sending empty body | Missing required payload | POST /api with no data |
Using unsupported file types | Wrong upload format | Uploading .exe instead of .png |
These seem small but can cause major request failures.
Common Fixes for 415 Errors
If you're encountering a 415
error, here are the most common solutions:
Add the Missing Content-Type Header:
POST /api/users HTTP/1.1Content-Type: application/json
Correct the Content-Type Header:
# Before (wrong):
Content-Type: text/plain
# After (correct):
Content-Type: application/json
Convert Your Data to a Supported Format:
If the server only accepts JSON, make sure you're sending proper JSON, not XML or form data.
Check for Typos:
# Wrong:
Content-Type: application/jason
# Correct:
Content-Type: application/json
Advanced Considerations
Content Negotiation
Some sophisticated APIs support content negotiation, where the client can specify what formats it can accept using the Accept
header:
GET /api/users/123 HTTP/1.1Accept: application/json, application/xml;q=0.9
This tells the server "I prefer JSON, but I can accept XML if necessary."
Charset Parameter
For text-based formats, you might need to specify the character encoding:
Content-Type: application/json; charset=utf-8
Conclusion: The Importance of Clear Communication
The HTTP 415 Unsupported Media Type
status code highlights a fundamental aspect of web communication: both parties need to agree on the "language" they're using to exchange data. It's not enough to send the right data you have to send it in the right format and properly announce what that format is.
HTTP 415 Unsupported Media Type is a key part of ensuring that servers only process expected and compatible data formats. Correctly handling Content-Type headers, following API specs, and testing with tools like Apidog can drastically reduce these errors.
Understanding and properly handling 415
errors will make you a more effective API consumer and a better API designer. By paying attention to content types and providing clear communication between clients and servers, you can avoid these frustrating errors and build more robust integrations. Remember APIs thrive on clear communication between the client and the server. If they speak the same “language” (in this case, media type), everything runs smoothly.
So the next time you encounter a 415
error, remember it's not a complex server failure it's a simple communication issue that's usually easy to fix. And when you're building or testing APIs, using a tool like Apidog will help you ensure that your content types are always correct, preventing these errors before they happen.