Invalid Content-Type Header Error
Fix 'Invalid Content-Type' errors when the request Content-Type header does not match the request body format.
What Does This Error Mean?
The 'Invalid Content-Type' error occurs when the Content-Type header in a request does not match the actual format of the request body, or the server does not support the specified media type.
Common Causes
Sending JSON body with Content-Type: application/x-www-form-urlencoded
Forgetting to set Content-Type header at all
Typo in the content type string (e.g., 'application/json' instead of 'application/json')
Using text/plain when server expects application/json
Not including charset with Content-Type when required
How to Fix It
Set correct Content-Type for your body format
Match the Content-Type header to the actual format of your request body.
// JSON body
fetch("/api/data", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ key: "value" }) // ✅ Correct
})
// Form data (let browser set Content-Type automatically)
const formData = new FormData()
formData.append("file", fileInput.files[0])
fetch("/api/upload", { method: "POST", body: formData }) // ❌ Don't set Content-Type manually for FormDataCheck for typos
Even a small typo in Content-Type will cause it to be unrecognized.
// ❌ Common typos "application/json" // extra double quote "application/json" // missing slash "applicaiton/json" // misspelled "Application/JSON" // wrong case // ✅ Correct "application/json" "application/x-www-form-urlencoded" "multipart/form-data"
Verify server expectations
Check API documentation for the exact Content-Type the server expects.
// API expects
Content-Type: application/json
// But you sent
Content-Type: text/plain
{"key": "value"}
// Server cannot parse plain text as JSON → 400 or 415Related Tools
Use these tools to debug and fix this error:
Related Errors
Other common errors in this category:
401 Unauthorized Error
Learn what a 401 Unauthorized error means, common causes, and how to fix authentication failures in your web applications.
403 Forbidden Error
Learn what 403 Forbidden means, how it differs from 401, and how to fix access denied errors in your applications.
404 Not Found Error
Learn what 404 Not Found means, common causes, and how to fix broken links and missing resources on your website or API.
429 Too Many Requests Error
Learn what 429 Too Many Requests means, how rate limiting works, and how to handle or avoid hitting API rate limits.