Postman cheatsheet
A one-page reference for Postman. For workspace organization and interview Q&A, see the complete guide.
๐ Full guide: Postman โpm.* test scriptsโ
pm.test("status is 200", () => {
pm.response.to.have.status(200);
});
pm.test("has user id", () => {
const json = pm.response.json();
pm.expect(json.id).to.be.a('number');
});
Pre-request scriptsโ
pm.environment.set("timestamp", Date.now());
pm.request.headers.add({
key: "X-Signature",
value: computeHmac(pm.environment.get("secret"))
});
Chaining requestsโ
// in a "Login" request's Tests tab
pm.environment.set("authToken", pm.response.json().token);
// next request uses {{authToken}} in its Authorization header
Collection Runner (data-driven)โ
Runner โ select collection โ select CSV/JSON data file
โ each row runs the whole collection once, {{variables}} pulled from row
Newman โ CI executionโ
newman run collection.json -e env.json \
--reporters cli,junit --reporter-junit-export results.xml
Mock serversโ
New โ Mock Server โ pick collection
โ returns saved example responses without hitting the real backend
Useful for frontend teams to develop against before the API exists.
Environments & variablesโ
{{baseUrl}}/users/{{userId}}
Scope order (highest wins): Local โ Environment โ Collection โ Global.
Postman vs Rest Assuredโ
| Postman | Rest Assured | |
|---|---|---|
| Authoring | GUI + JS | Java code |
| Version control | export JSON (noisy diffs) | native, clean diffs |
| Best for | exploratory, quick checks | CI-integrated regression suites |