50% OFF Residential Proxies for 9 months — use code IPR50 at checkout

Get The Deal
Back to blog

What Is a 415 Status Code? Causes, Fixes, and Best Practices

Kazys Toleikis

Last updated -
Proxy fundamentals

Key Takeaways

  • The 415 status code indicates that the server can’t handle the format due to a wrong or missing header.

  • Always validate your payload format and Content-Type header to prevent the “Unsupported Media Type” pitfall.

  • Employ best practices to prevent getting these errors in the future.

Ready to get started?

Register now

When you send an API request and receive a 415 error code, what you’re seeing is an HTTP status code that means “Unsupported Media Type”. In short, the server refuses your request because it doesn’t support the format you’re sending.

This error code is commonly encountered in REST APIs when the Content-Type headers are wrong or missing.

What Does the 415 Status Code Mean?

A 415 status code is an HTTP status code indicating “Unsupported Media Type”. It appears when a server can’t process the payload format sent in the request, usually due to mismatches in the header.

This HTTP status code happens mostly in REST APIs when you send JSON data or XML, but don’t set the header right. You might also encounter “415 Unsupported Media Type” errors when you use tools like Postman or curl.

What Does a 415 Error Look Like?

Here are some common versions of the 415 status code in different tools and what each of them means.

Postman

Example Request

  • Method: POST
  • Headers:
Content-Type: application/x-www-form-urlencoded
  • Body (raw JSON):
{
  "user": "belgin",
  "comment": "LGTM!"
}

Response

HTTP/1.1 415 Unsupported Media Type
Date: Fri, 28 Jun 2024 12:00:00 GMT
Server: Apache/2.4.41 (Ubuntu)
Accept-Post: application/json; charset=UTF-8
Content-Length: 0

What It Means

  • 415 Unsupported Media Type indicates that the server refuses the request due to mismatched Content-Type header.
  • Accept-Post: application/json; charset=UTF-8 indicates which media type the endpoint expects.

cURL

Example Request

curl -X POST \
  -H "Content-Type: text/plain" \
  -d '{"name":"John","age":30}' \
  https://example.com/comments

Response

HTTP/1.1 415 Unsupported Media Type
Server: Apache/2.4.41 (Ubuntu)
Accept-Post: application/json; charset=UTF-8
Content-Length: 0

Explanation

  • You used text/plain, but the server expected JSON.
  • The request body is in JSON format, so header mismatch triggers the 415 status code.

API Logs or Browser DevTools

Browser Request

POST /comments HTTP/1.1
Host: example.com
Content-Length: 23

{
  "user": "belgin",
  "comment": "LGTM!"
}

Response

HTTP/1.1 415 Unsupported Media Type
Date: Fri, 28 Jun 2024 12:00:00 GMT
Server: Apache/2.4.41 (Ubuntu)
Accept-Post: application/json; charset=UTF-8
Content-Length: 0

Explanation

  • Missing or wrong header means the server can’t parse the body.
  • Accept-Post gives hints on the expected input format.

Common Causes of 415 Errors

  • Wrong header. For example, using Content-Type: text/html instead of application/json.
  • Missing header. The server doesn’t recognize the format and rejects it.
  • Mismatched payload. Sending XML while the API expects JSON causes the “Unsupported Media Type” error.
  • Wrong JSON data. Even with the correct header, badly formatted data fails parsing.
  • The server is too strict. Some APIs reject slight deviations in the Content-Type header, such as a missing charset.

How 415 Differs From 400, 403, and 406

Here is a brief overview that explains how each of these HTTP status codes differ.

HTTP status code Meaning When it occurs
400 Bad Request Generic syntax error Wrong JSON, missing fields
403 Forbidden Auth approved, but action not allowed No valid credentials or permissions
406 Not Acceptable Client’s Accept header doesn’t match Server can’t serve the requested media type
415 Unsupported Media Type Wrong header or payload Payload format unsupported

To sum it up:

  • 400 shows wrong syntax like missing brackets in your JSON.
  • 403 is about access rights, not payload itself.
  • 406 shows that the server can’t respond in the format you requested via the Accept header.
  • 415 is specific to format mismatch or a bad header.

How to Fix 415 Status Code Errors

Now that you know what the HTTP status code is all about, let’s see how you can fix it properly. Keep in mind that some coding experience will help you out a lot with the solution.

  • Verify that the header value matches what the server expects.
  • Make sure that the server can process your Content-Type header.
  • Use the Accept header to check what your server can process.

If you don’t feel comfortable with these steps or have no coding knowledge, it might be better for you to find a professional that can help you fix the HTTP status code.

Best Practices to Prevent 415 Errors

It’s always best to prevent something instead of letting it malfunction. Follow these best practices to minimize your chances of getting the HTTP status code again:

  • Always include a correct Content-Type header.
  • Make sure your data has no syntax errors.
  • Double-check what format the server accepts.
  • Make sure you comply with all API requirements.

Conclusion

“415 Unsupported Media Type” error occurs when your header doesn’t match the actual format. It’s usually easy to fix, especially if you have some coding knowledge.

If you don’t you may want to leave it to a professional so fix this HTTP status code for you and ask them to show you in action what to do to prevent it happening in the future.

Create Account

Author

Kazys Toleikis

Head of Client Support

Kazys brings a strategic and disciplined approach to client support thanks to his leadership background, as well as vast experience in tactical planning and crisis management. He focuses on team leadership, customer satisfaction, and process improvement, ensuring efficient collaboration across departments. Known for his sharp decision-making and ability to stay calm under pressure, he is dedicated to delivering top-tier support no matter the challenge. After hours, Kazys enjoys staying active and exploring new opportunities for growth, both personal and professional.

Learn More About Kazys Toleikis
Share on

Related articles