skip to content

Reviewing a Postman collection diff, how do you tell what a request's body actually puts on the wire?

level: seniorimportance: should knowfreq 33%

answer

  1. Two decisions, made in two different places
  2. The tag, not the payload text, is authoritative
  3. A declared header beats anything derived
  4. A leftover payload key sends nothing

basics

~10 s

Read body.mode first and treat only the key it names as the payload; sibling payload keys are inert. Then read the declared headers, because a declared Content-Type outranks anything derived from the raw language.

solid answer

~40 s

Two independent places decide what goes out, so ask two questions in order. First, **which payload key is live**: `body.mode` names it, and any other payload key left over from an earlier edit is inert text — a diff touching it changes nothing that runs, while a one-word change to `mode` changes everything. Second, **which `Content-Type` goes out**: a header declared on the request wins outright, and only when none is declared does the runtime derive one from `body.options.raw.language` and add it flagged `system: true`. Then remember that a pre-send script can rewrite headers, so a value matching neither source came from code. Delete stale payload keys rather than editing them; an edit to a dead key reads as a change and is not one.

code

json · 9 lines
json
{
  "body": {
    "mode": "formdata",
    "raw": "{\"legacy\":true}",
    "formdata": [
      { "key": "note", "type": "text", "value": "live payload" }
    ]
  }
}

go deeper

for a junior

Be ready to say you read body.mode first and then only the key it names. Knowing that other payload keys in the same object are not sent is the core of the answer.

for a middle

Explain both decisions mechanically: the tag selects the payload key, and a declared Content-Type outranks the header derived from a raw language, which is added only when none is declared.

for a senior

Show the review judgment. Flag mode changes as behaviour changes, insist stale payload keys are deleted rather than edited, and check pre-send scripts when a header matches neither the document nor the derivation.

for a principal

Own how shared collections are reviewed at all: what a body diff must show before approval, whether content types are declared explicitly by convention, and how file-referencing payloads are provisioned so any runner reproduces the request.

## A body review answers two questions, not one A stored request's payload is decided in two independent places, and a review that reads only one of them will confidently describe a request that does not exist. The two questions are: 1. **Which payload key is live?** Answered by `body.mode`. 2. **Which `Content-Type` goes out?** Answered by the request's declared header list first, and only then by anything derived from the body. Getting an argument settled quickly is mostly a matter of asking those two in that order, and refusing to reason from the payload text at all until both are answered. ## Step one: `mode` names the live key The `body` object in a collection file is a tagged union. `body.mode` carries one of `raw`, `urlencoded`, `formdata`, `file` or `graphql`, and the payload sits under the key of that same name. The **collection format** declares this, so every reader of the file agrees. The failure mode this creates in a long-lived document is stale siblings. A request edited from one shape to another can end up holding two payload keys at once — say a `raw` string left over beside the `formdata` list that `mode` now names. Nothing is ambiguous to the machine; the tag decides. But to a reviewer scanning a diff for "the body", the stale key is a trap: - A diff that changes `body.raw` on a request whose `mode` says `formdata` **changes nothing that runs**. - A one-word diff that changes `mode` **changes everything that runs**, while touching no payload text at all. - A payload key with no matching `mode` is document weight: it shows in reviews, it invites edits, and it sends nothing. That asymmetry is why `mode` is the first line to read in a body diff and the last one to wave through. ## Step two: the declared header outranks the derivation The second question is the one that produces "but I set it to JSON" arguments. Beside a `raw` payload a request may carry `body.options.raw.language`, and from that the runtime can add a `Content-Type` header, marked `system: true` to record that the runtime supplied it rather than the author. That add happens **only when the request declares no `Content-Type` of its own**. | what the request declares | effect of the raw `language` | |---|---| | no `Content-Type` header | a derived header is added, flagged `system: true` | | a `Content-Type` header the author typed | the author's header stands; nothing is derived | So a request can be fully "configured" on the body side and still send a content type the body side never mentions. When someone reports that changing the language did nothing, they are usually right, and the header list says why. ## A checklist that fits on one screen 1. Read `body.mode`. Write down the one key it names. 2. Read that key only. Ignore every sibling payload key, and flag it for deletion rather than editing it. 3. Read the declared headers. A `Content-Type` there is what goes out. 4. If there is no declared `Content-Type` and the mode is `raw`, then and only then does `options.raw.language` decide the header. 5. Remember that a script running before the send can also edit headers, so a header that matches neither the document nor the derivation came from code. ## What to do about the stale key Delete it. A payload key that `mode` does not name has no runtime meaning, and leaving it in place is not conservatism — it is a decision deferred onto the next reader, who has to work out all over again whether it matters. The one thing not to do is edit it: an edit to a dead key looks like a change to the request in every review tool and is a change to nothing at all. ## The judgment worth showing - **Trust the tag, not the text.** The presence of a plausible payload is not evidence that it is sent. - **Trust the declared header, not the annotation.** An explicit statement outranks a convenience, always. - **Treat a `mode` change as a behaviour change** in review, with the same care as a URL or method change, because it moves which key is read. - **Treat a file-referencing payload as an environment dependency**, since the bytes live outside the document and the document alone does not prove the run will work elsewhere. What a media type *means* to the server, and how it negotiates among several, is HTTP's own subject and is not settled by reading this file. What the file settles — and settles completely — is which key is the payload and which header the runtime will and will not add.

  • Why treat a one-word change to body.mode as a bigger review event than a rewritten payload?
    Because `mode` moves which key is read. Rewriting the payload under the live key changes the content of a request that still has the same shape; changing `mode` swaps the shape and can silently promote a stale sibling key written long ago. It is a behaviour change disguised as a spelling change.
  • A request sends a Content-Type that matches neither the declared header nor the raw language. Where do you look?
    At the scripts that run before the send. The document and the derivation are the only two sources the file itself describes, so a third value means code edited the headers at run time. Read the request's own pre-send script, then any inherited from its parents.

saying these in an interview costs you the question

  • Reads the payload text before reading the mode tag
  • Edits a stale payload key instead of deleting it
  • Assumes a declared Content-Type is what the language produced
  • Treats a mode change as a cosmetic diff
  • Forgets pre-send scripts can rewrite the header list