← REST API Development learning path
REST API Development · Module 5 of 10

Request and response formats

Structure JSON bodies, headers and error responses.

📖 Key ideas

  1. Send JSON with Content-Type: application/json.
  2. Accept header tells the server what the client wants.
  3. Use consistent error bodies: { "error": { "code", "message" } }.
  4. Dates in ISO 8601: 2026-10-14T10:30:00Z.
  5. Never return passwords or secrets.
💡 Real-life example: Headers are the envelope; the body is the letter inside.
Content-TypeFormat of the body sent
AcceptFormat the client wants back
ISO 8601Standard date-time format
Error bodyJSON explaining what went wrong