Skip to content
BENIBIX Learn

Response Body

Development🔌 APIsAPI Basics

Also known as HTTP Response Body, Response Payload, Response Content

The data a server sends back in a web reply, after the headers. It is what you asked for.

Think of it like

It is like the gift in a box. The label is on the outside, and the gift is inside.

Example

Emma's app asks an API for user 42. The response body holds that user as JSON, with a name of Lucy.

Why it matters

It is the part of a reply your code reads. Every API call ends with code that unpacks this body.

Definition

The response body is the data a server sends back after the headers in a web reply. It is the thing you asked for: a web page, a picture, or data such as JSON. A header called Content-Type says what format it is in. A blank line separates the headers from the body. Some replies have no body at all, like a 204 No Content reply or the answer to a HEAD request.

Example code

http
HTTP/1.1 200 OK
Content-Type: application/json

{"id": 42, "name": "Lucy"}
The status line, one header, a blank line, then the JSON body.
The body comes last, after the status line, the headers and a blank line.

Common mistake

Reading the body before checking the status code. An error reply has a body too, and it is not the data you wanted.

Key takeaways

  1. 1
    After the headers. Past a blank line.
  2. 2
    What you asked for. A page, a file or data.
  3. 3
    Typed by a header. Content-Type says the format.