Back to Cheat SheetsAPI · Beginner
Postman cheat sheet
Variables, scripts, collection runs and Newman in CI.
Variables
Use variable
{{baseUrl}}/users/{{userId}}Set from response
pm.environment.set("userId", pm.response.json().id);Scope order
local > data > environment > collection > globalTests
Status
pm.test("ok", () => pm.response.to.have.status(200));Body field
pm.expect(pm.response.json().email).to.eql("qa@test.io");Schema
pm.response.to.have.jsonSchema(schema);Newman
Run collection
newman run api.json -e qa.json -r cli,htmlFail the build
Newman exits non-zero on failure
newman ... || exit 1Go beyond the reference
Book a free demo class and apply these commands on live project work.