Status
http
415 Unsupported Media Type
Examples
Missing content type
In the following example, the Content-Type header is missing entirely:
http
POST /comments HTTP/1.1
Host: example.com
Content-Length: 23
{
"user": "belgin",
"comment": "LGTM!"
}
If the server implementation expects at least a MIME type Content-Type: application/json; for the request at that endpoint, it may send the following response:
http
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
Invalid content type
In the following example, the Content-Type header is incorrectly set to URL-encoded form data when the content is in the request body instead:
http
POST /comments HTTP/1.1
Host: example.com
Content-Length: 23
Content-Type: application/x-www-form-urlencoded
{
"user": "belgin",
"comment": "LGTM!"
}
In this case, the server responds with a 415, with the required content type for the request in the Accept-Post header:
http
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
Specifications
| Specification |
|---|
| HTTP Semantics # status.415 |