Navigation
Introduction
HTTP Status Code 415-Unsupported Media Type is one of the classes of 4xx(Server Error) response code that indicates the server is refusing to accept the request because the payload format is unsupported.
The format issue might be caused by the request’s Content-Type or Content-Encoding, or it could be caused by reviewing the data directly.
General Understanding
A server should return 415 Unsupported Media Type if it gets a request with a body it doesn’t recognize. This is a suitable answer for a POST or PUT request with an unknown Content-Type header, for example.
According to the standard, the server may additionally return this after analyzing the body, in addition to inspecting the Content-Type header.
This implies that even if the client sends a request with a valid Content-Type, the server may still return 415 if the request body’s contents aren’t supported by the server.
Status
415 Unsupported Media Type |
Examples
For example, a server may allow specified JSON bodies, yet the JSON payload’s contents failed to verify, maybe due to the absence of a needed attribute.
In the latter situation, though, 422 Unprocessable Entity may be preferable. The standard explanation for 422 differs significantly from that for 415, however, 422 appears to be more particularly for circumstances where the Content-Type was valid, the request was parsable, but the semantics were erroneous.
POST /new-article HTTP/1.1 Content-Type: text/html <h1>Another day, another blog post</h1> |
HTTP/1.1 415 Unsupported Media Type Content-Type: application/json {“error”: “This endpoint only supports text/markdown for new articles”} |
Causes
When a correct Content-Type header is not given, a 415 Unsupported Media Type HTTP status code is delivered.
How Do I Fix a 415 Unsupported Media Type?
Fixing a 415 error might take a long time for the client since it signals that the problem is with what the client is delivering that the webserver is unable to handle. To put it another way, if you get a 415 error, that implies you have to solve it yourself.
The three most popular approaches to repair a 415 Unsupported Media Type are as follows:
1. Check that the Content-Type header value you’re sending is correct. 2. Confirm that the Content-Type header value can be processed by the server. 3. To see what the server can handle, look at the Accept header. |
Specifications
Specification | Title |
RFC 7231, section 6.5.13: 415 Unsupported Media Type | Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content |
Related Articles
HTTP Status Code 204 – No Content |
HTTP Status Code 300-Multiple Choices |
HTTP Status Code 302 Found |
HTTP Status Code 207 Multi-Status |
FAQ
What does HTTP Status Code 415 mean?
415 Status Code is one of the classes of 4xx(Server Error) response code that indicates the server is refusing to accept the request because the payload format is unsupported.
What’s the difference between an error code of 422 Unprocessable Entity and a code of 415 Unsupported Media Type?
The 422 description in the standards differs somewhat from the 415 descriptions. When a client requests an XML document that the server is unable to parse, the 422 error is returned, and 415 denotes an unsupported media type.
Is Status Code 415 a Server-Side or a Client-Side Error?
The 415 Unsupported Media Type status code is a client-side error.
It belongs to the 4xx group of HTTP response status codes, generally known as client errors.
Conclusion
The 415 Unsupported Media Type error number indicates that the request entity is using a media type that the server or resource does not support.
The easiest approach to repair the problem is to double-check that the Content-Type header value you’re providing is correct.
I hope this article was able to help you with your doubts and queries related to the HTTP status code 415 (Unsupported Media Type). Still, if there are any queries related to this topic, feel free to ask in the comment section, we would be happy to assist you. Thank you.
Saurabh Chalise