What Does 415 Unsupported Media Type Mean?
A 415 unsupported media type error occurs when the origin server refuses a particular request since the resource is in a format that is not supported by the server for the HTTP method used. This unsupported format type issue can be caused by what is defined in the resource’s Content-Type or Content-Encoding headers.
The 415 error is somewhat related to the 406 error in that they both occur due to media type related issues. However, the 406 error is not triggered based on the value within the Content-Type or Content-Encoding headers, but rather the value within the Accept HTTP header.
The Content-Type header can be included in both request and response headers and is used to tell the server what the data actually is. An example of this is a form submission on a website. The form submission will use a POST method and thus send data to the server. In order for the server to know what type of data is being sent, the Content-Type header is included in the request. However, if the server is unable to process the Content-Type value of this request the client will receive a 415 unsupported media type response.
Fixing 415 Unsupported Media Type Errors
Fixing 415 errors can be a bit tricky as they are largely dependant upon what the client is sending and what the web server is able to process. A couple of things to look out for when trying to resolve 415 errors include:
- Ensure that you are sending the proper Content-Type header value
- Verify that your server is able to process the value defined in the Content-Type header
- Check the Accept header to verify what the server is actually willing to process
In summary, to fix 415 unsupported media errors you need to examine what content types the origin server is able to process, as well as what the client is trying to request. Based upon that information, you can either modify the request to send a compliant Content-Type header or configure the server to accept the Content-Type value sent via the client.