Repaso
Español
Backend & APIsCoreAPI-41

What does the request header Content-Type: application/json tell the server?

Options

  1. The client wants JSON back in the response
  2. The body of this request is formatted as JSON (Correct option)
  3. The request is encrypted before it is sent
  4. The user is already logged in

Answer

The body of this request is formatted as JSON

Why

Content-Type describes the format of the body being SENT. With application/json the server knows to parse the body as JSON.

To say which format you want BACK, the client uses the Accept header.

If the header is wrong or missing, many frameworks reject or misread the body.

Remember

Content-Type = format of what I send. Accept = format I want back.

Key terms

Practice this question in Repaso