Content-Type / MIME Type

The header that tells the other side what format the body is in, like application/json or image/png. Wrong label, unreadable data.

the application/json headerit says wrong formatmime typemedia typemimetypecontent type header415 unsupported media typethe header that says what format the body iswhy is my request body empty

See it

Live demo coming soon

What it is

A MIME type (officially a media type now) is a short label like 'application/json', 'image/png', or 'text/event-stream' that says what format a chunk of bytes is in. The Content-Type header attaches that label to a body: on a request it means 'here is what I am sending', on a response 'here is what I am returning'. Its cousin Accept says 'here is what I would like back'.

The four you will actually meet: 'application/json' for API payloads, 'application/x-www-form-urlencoded' for classic HTML form posts, 'multipart/form-data' for file uploads, and 'text/event-stream' for server-sent events. Add 'charset=utf-8' on text types so accented characters survive the trip.

Gotcha: a mismatched Content-Type is a common cause of an empty req.body and a baffling 400 or 415. If you JSON.stringify a body but leave the default header, the server's JSON parser never runs and your handler sees nothing. Second gotcha: never echo back a user-uploaded file's claimed type. Browsers will sniff and execute HTML you serve as an image, so pin the type server side and send 'X-Content-Type-Options: nosniff'.

Ask AI for it

Audit and fix Content-Type handling across this integration: send 'Content-Type: application/json; charset=utf-8' with every JSON request body, send 'multipart/form-data' only for file uploads (and let the runtime set the boundary), set an explicit 'Accept' header on outbound calls, and check the response Content-Type before parsing so an HTML error page never reaches JSON.parse. On any endpoint that serves user-uploaded files, set the type from server-side detection and add 'X-Content-Type-Options: nosniff'.

You might have meant

payloadrequest headersmultipart form dataserialization deserializationhttp status codes