skip to content

Why can a saved example's `originalRequest` disagree with the Postman item's own `request`?

level: middleimportance: must knowfreq 55%

answer

  1. It is a copy, not a reference
  2. Nothing synchronises the two
  3. A whole request, embedded in the example
  4. Editing one never touches the other
  5. Snapshot of a call made once

basics

~20 s

A saved example's originalRequest is a whole embedded request definition, not a pointer back at the item. Editing the item's own request never touches that copy, so the example keeps documenting a call the request no longer makes.

solid answer

~40 s

In the collection format a saved example sits in an item's `response` array and carries its own `originalRequest` — a complete request definition with its own `method`, `url`, `header` and body. It is embedded, not referenced: the SDK builds it as a separate `Request` from the example's own JSON, and nothing links it back to the item's `request`. So when someone renames a path, switches `POST` to `PUT`, or adds a required header on the item, the example keeps the old shape. The two drift apart silently, because neither the format, the SDK nor a collection run ever compares them. Treat `originalRequest` as a dated snapshot and re-capture the example in the same change that alters the request.

code

json · 23 lines
json
{
  "name": "Update user",
  "request": {
    "method": "PUT",
    "url": "https://api.example.com/v2/users/42",
    "header": [{ "key": "If-Match", "value": "{{etag}}" }]
  },
  "response": [
    {
      "name": "200 updated",
      "originalRequest": {
        "method": "POST",
        "url": "https://api.example.com/v1/users/42",
        "header": []
      },
      "status": "OK",
      "code": 200,
      "header": [],
      "cookie": [],
      "body": "{\"id\":42}"
    }
  ]
}

go deeper

for a junior

Be ready to say that a saved example stores its own full copy of the request that produced it, so changing the request in the item leaves the example's copy exactly as it was.

for a middle

Explain the mechanics: originalRequest is a whole embedded request definition, the SDK constructs it as an independent object with no back-reference, and no layer compares it against the item's request.

for a senior

Demonstrate the review habit this creates — reading the response array in collection diffs, re-capturing examples in the same change as the request, and knowing a green run proves nothing about them.

for a principal

Own the policy question of how many examples the team maintains and who is accountable when one goes stale, since every embedded copy is documentation debt that no tooling will collect for you.

## `originalRequest` is a copy, not a link Inside a Postman collection file, an item holds one `request` and an array of saved examples under `response`. Each saved example carries an `originalRequest` field, and the crucial fact is what that field contains: **a whole request definition**, structurally identical to the item's own `request` — its own `method`, its own `url`, its own `header` array, its own body, its own `auth`. It is not an id, not a path, not a `$ref`, not a diff. It is a **second copy of a request**, physically stored inside the example. The SDK makes this explicit. When it builds a `Response` from a saved example, an `originalRequest` in the definition is turned into a brand-new `Request` object constructed from the example's own JSON. That object holds no back-reference to `item.request`. There is no getter that resolves one from the other and no synchronisation step anywhere. ## How the two drift apart Because they are two copies, ordinary editing separates them: 1. Someone renames a path segment, or moves the endpoint to a new host, on the item's `request`. 2. Someone switches the verb — a create that was `POST` becomes `PUT`. 3. Someone adds a required header, or a new field in the request body. 4. Someone parameterises a hardcoded id into a variable. Each of those touches `item.request` only. The saved example beside it keeps whatever it captured, possibly months earlier: | | `item.request` | the example's `originalRequest` | |---|---|---| | What it is | The request the item actually sends | A frozen snapshot of one past call | | Who updates it | Anyone editing the request | Only someone re-capturing the example | | Effect of editing the other | None | None | | Checked against the other | Never | Never | The result is an example that documents a call the API no longer accepts, sitting under a request that would work fine. ## Nothing detects the divergence This is the part candidates usually miss. There is no layer that notices: - The **collection format** declares `originalRequest` as an optional field with a request-shaped value. It expresses no relationship at all between it and the item's `request`. - The **SDK** constructs both and never compares them. Building the collection succeeds whatever they say. - A **collection run** does not consult saved examples, so a fully green run tells you nothing about whether they are current. So the drift is silent by construction. The file stays valid, tooling stays quiet, and the only signal is a human reading the example and noticing it does not match. ## Why the copy exists at all The design is deliberate, and it has a real upside. Because the example embeds the request that produced it, the pair is **self-describing**: you can read one saved example and know exactly which call yields that body, including the headers and the exact URL, without reconstructing anything from the item around it. That is what makes an example usable as documentation, and what makes it portable when a single example is copied elsewhere. It also means an example can legitimately differ from the item. A `404` example naturally uses a different id in its `originalRequest` than the `200` example next to it, and both differ from whatever the item's request currently points at. **Difference is not automatically a defect** — which is precisely why no tool can flag it for you. ## Working with it Practical habits that follow from the mechanism: - Treat every `originalRequest` as **dated**. It is evidence about the past, not the present. - Re-capture examples in the **same change** that alters the request, exactly as you would update a code comment that a refactor invalidated. - When reviewing a collection diff in version control, read the `response` array, not only the `request`. A change that touches `request` and leaves `response` untouched deserves a question. - When an example is used as reference material by other people, its staleness is a documentation bug with the same cost as a wrong README, so give it the same review attention. - Prefer fewer, curated examples over many stale ones. Each one is a copy somebody must maintain. The short version to say out loud: `originalRequest` is an embedded request, not a pointer, so the item's request and its examples are two independent copies that only discipline keeps aligned.

  • Is a difference between `originalRequest` and the item's request always a defect?
    No. Examples covering different outcomes legitimately differ: a `404` example points at an id that does not exist, while the `200` example next to it points at one that does. Both differ from whatever the item currently sends. That is exactly why no tool can flag divergence automatically — a difference carries no inherent meaning, so only a reader can judge it.
  • What would you look for when reviewing a collection change in version control?
    Whether the diff touches an item's `request` while leaving its `response` array untouched. That pattern is the signature of an example going stale: the call changed and its documented snapshot did not. Ask for the example to be re-captured in the same change, exactly as you would ask for a comment invalidated by a refactor to be updated.
  • Does the SDK give you any link from a saved example back to the item's request?
    No. When the SDK builds a `Response` from a saved example, an `originalRequest` in the definition becomes a brand-new `Request` object constructed from the example's own JSON. It holds no back-reference to the item's `request`, and there is no getter that resolves one from the other. If you want a comparison, you write it yourself.

It is a photograph of the request, not a mirror of it: the item can be repainted any number of times and the photo on the wall keeps showing the old colour.

saying these in an interview costs you the question

  • Calls originalRequest a pointer or reference to the item's request
  • Expects editing the request to update every saved example
  • Thinks the format's schema validates the two against each other
  • Believes a collection run refreshes stale examples automatically
  • Assumes any difference between the two is always a bug
  • Says the SDK exposes a link from example back to item