415 Unsupported Media Type
HTTP response status code 415 Unsupported Media Type is a client error that is returned by the server to indicate that the content of a message body is not supported.
When the 415 Unsupported Media Type error message is received, it may be as a result of the Content-Type or Content-Encoding headers being rejected by the server. Alternatively, the server may return this error based upon further inspection of the message body.
In the latter case, the server may indicate this error because it has trouble parsing or otherwise deciphering or recognizing the content. In cases where the server recognizes the media but it is not supported, the 415 Unsupported Media Type status is most accurate. However, if the content cannot be parsed and may contain an error then HTTP response 400 Bad Request or 422 Unprocessable Entity may be more appropriate.
Search engines like Google will not index a URL with 415 Unsupported Media Type response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.
In the example, the client wants to send a message in plain text, but the server sends the 415 Unsupported Media Type error because it only accepts HTML messages. The client subsequently changes the Content-Type header but leaves the original message intact. The server can recognize that it is not a valid HTML structure and consequently, denies the request a second time.
POST /blog/newmessage HTTP/1.1 Host: www.example.ai Content-Type: text/plain Content-Length: 24 Good morning, Everybody!
Initial response, based on examining the Content-Type header
HTTP/1.1 415 Unsupported Media Type Content-Type: text/html Content-Length: 138 <html> <head> <title>Unsupported Format</title> </head> <body> <p>Please use HTML to post new messages.</p> </body> </html>
Subsequent request to attempt to fool server
POST /blog/newmessage HTTP/1.1 Host: www.example.ai Content-Type: text/html Content-Length: 24 Good morning, Everybody!
Subsequent response, based on examining the message body
HTTP/1.1 415 Unsupported Media Type Content-Type: text/html Content-Length: 174 <html> <head> <title>Unsupported Format</title> </head> <body> <p>No HTML tags were found. Please ensure you use HTML to post new messages.</p> </body> </html>
Apache HttpComponents Core
The 415 Unsupported Media Type status code is a client error that occurs when the client sends, or attempts to send, a message body to the server that contains an unsupported media type. It may be denied based on the Content-Type or Content-Encoding headers, or after inspection of the message body.