The 415 Unsupported Media Type HTTP status code indicates that the server refuses to accept the request because the payload format is not supported. This usually happens when the Content-Type header does not match what the server expects.
Content-TypeHTTP requests that include a body (POST, PUT, PATCH) must specify a valid media type using the Content-Type header. If the server does not support that type, it responds with 415.
// Sending JSON data without proper Content-Type
fetch("/api/user", {
method: "POST",
body: JSON.stringify({ name: "Meghraj" })
});
The server responds with 415 Unsupported Media Type because the request does not specify Content-Type: application/json.
Select a header below to see how the server responds:
// Correct request with supported media type
fetch("/api/user", {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ name: "Meghraj" })
});
Content-Type headerContent-Type