Reference

MIME Types Reference

MIME types and Content-Type notes for API payload debugging.

Overview

MIME types describe the format of request and response bodies. In API debugging, the important question is whether the server and client agree on what the body contains. A wrong Content-Type can turn valid data into a parsing failure.

Debugging Reference Table

MIME typeTypical bodyAPI debugging note
application/jsonJSON object, array or primitiveRequired for most JSON request bodies and useful before calling response.json().
text/plainPlain textDo not assume it can be parsed as JSON even when it looks structured.
text/htmlHTML documentOften means a redirect, error page or login page was returned instead of API JSON.
application/x-www-form-urlencodedForm encoded key-value pairsSpaces and plus signs may need different handling than JSON.
multipart/form-dataFile upload or mixed form fieldsBoundary metadata is required; do not manually hardcode it in most browser requests.
application/octet-streamBinary dataTreat as bytes, not text.
image/svg+xmlSVG XMLUseful for assets but should not be parsed like JSON.
application/problem+jsonStandardized error objectParse as JSON, but expect an error shape such as title, detail and status.

Reference Table Coverage

  • Request Content-Type headers.
  • Response body parsing decisions.
  • HTML returned to JSON clients.
  • Form encoding versus JSON encoding.

API Debugging Examples

  • A POST request sends a JSON string but omits Content-Type: application/json.
  • A browser fetch receives text/html because an auth redirect returned a login page.
  • A problem+json response should be parsed as structured error data.

Common Mistakes

  • Calling response.json() without checking Content-Type.
  • Manually setting multipart boundaries in browser upload requests.
  • Assuming text/plain means the server did not return useful error details.
  • Sending URL-encoded form data to an endpoint expecting JSON.

FAQ

Should I always trust the Content-Type header?

It is the best first signal, but servers can mislabel responses. If parsing fails, inspect both headers and body.

Why do I get HTML from an API endpoint?

Common causes include redirects, authentication pages, proxy errors and framework error pages.

Is application/problem+json valid JSON?

Yes. It is a JSON-based format commonly used for structured API error responses.