Build a request and its checks

Fill a request in, say what a pass means with checks, and keep values for the next request.

In short

A saved request opens in an editor where you set the address, method, params, headers, body and sign-in. Checks say what a pass means - a status, a header, a value in the body, a time, a schema - so a 200 with the wrong body still fails. "Keep a value" passes a value on to the next request.

Before you start

Steps

  1. Open a saved request. The editor opens beside the list.
  2. Type the address, pick the method, then use the tabs for params, headers, body and sign-in. Type {{ to pick a variable.
  3. Press "Send", or Ctrl or Cmd with Enter. "Save" keeps your changes.
  1. Open "Checks" on the request and press "Add check".
  2. Choose what it looks at (see the table) and what you expect.
  3. Read pass or fail against the last answer as you fill it in, and save.
  1. Under "Keep for the next request", press "Keep a value".
  2. Name the variable and say where to read it: the body (a JSONPath) or a header.

Result: after the request runs, its checks pass or fail, and later requests and suite steps can use the kept value as {{name}}.

Start from an answer Send the request once, then click a value in the answer. You can turn it into a check or keep it as a variable without writing anything by hand.

Checks: what a pass means

Every check runs even after one fails, so a request with five checks says which of the five broke. An expected value can use a variable: "$.id equals {{orderId}}" compares the id with the value {{orderId}} has when the request runs.

Every item or any item

A path with [*] or a filter reaches many items - for example $.items[*].price. Which items must pass is your choice:

If you leave it alone, a path with [*] or a filter means every item, and any other path checks its one value. A path that reaches nothing fails, except when the check is "does not exist".

Check the shape with a JSON Schema

Choose "Matches a JSON schema" to check that the body has the right fields and types, not just one value. Paste a JSON Schema, or press "Start from the last answer" to write one from the answer's shape and then tighten it. A failed schema check lists the first places that do not match, each with its path and the reason. A request imported from OpenAPI that documents a response gets a schema check for free.

Redirects, certificates and cookies

GraphQL

Choose GraphQL as the body. Write the query, add variables as a JSON object such as {"id": 1}, and give an operation name only when the query holds more than one. Press "Load schema" to browse queries, mutations and subscriptions; it counts as one request. Then suggestions name only the fields or arguments that fit where you type, and the query is checked as you write it: each problem a server would refuse - a field or argument that does not exist, a required argument or variable value left out, braces missing after an object - is listed with its line, and a click goes to it. Under "Build", tick the fields you want and press "Use this query": the query is written for you, with a variable for each required argument. If the server says nothing, introspection may be turned off.

Copy a request as code

Open the request's "Code" tab, or "Code snippets" in its menu, and pick a language: cURL, JavaScript (fetch or axios), Python, C#, Go, Java or PHP. Variables stay as placeholders, so a secret is never written out - fill them in before you run it.

Good to know

If something goes wrong

Related