Testing APIs
Chaining and test data
Sign in first and reuse the token, pass an order id from one request to the next, and feed rows from a CSV file into your requests.
Three tabs let requests use values that only exist while a test runs:
| Tab | Use it when |
|---|---|
| Run first | This request needs something from another request first — usually a sign-in token |
| Save values | Later requests need something from this request's answer — like the id of what it created |
| Test data | You want many different users, ids, or inputs instead of one |
Run first
Send another saved request before this one and take values from its answer.
- Save your sign-in request (for example POST /login).
- Open the request that needs the token → Run first → choose the sign-in request.
- Under Values to take from its answer, say where the value is and what to call it: JSON field
data.access_tokenas{{token}}. You can also take a header, or use a text pattern (a regular expression; the part in brackets is kept). - Use
{{token}}anywhere — the button Use {{token}} as the Bearer token fills in Auth for you.
When does it run?
- Send: every time, just before the request. The response shows Ran first: Sign in · 200 and which values it found.
- Performance test: once, before the load starts; every request uses the same values.
- Collection run: once per run, even if several requests use it — later ones say reused.
If a value is not found, the request is not sent, and the message says which value and where it looked — so you can fix the path.
Save values
Take values from this request's answer for the requests after it — the id of a new order for Get order and Cancel order.
- Open the request that creates something (for example POST /orders) → Save values.
- Add a value: JSON field
idas{{orderId}}. - Use
{{orderId}}in the later requests:{{baseUrl}}/orders/{{orderId}}.
A whole record: save $ (the whole answer) or d.results[0] (an OData record) as {{employee}}, then use any field of it: {{employee.firstName}}, {{employee.address.city}}, {{employee.lines.0.sku}} for the first item of a list. One saved value gives a later request every field it needs, which is what a field mapping check uses.
Where it works:
- Collection run: every later request in the run can use the value. Put the creating request first in the run order. If a request needs a value that was not produced, it says why — “{{orderId}} is saved by ‘Create order’, which runs later — move it before this request”, or “…which failed”. If the value is missing from the answer, the creating request fails with “{{orderId}} was not found in the answer”, because the rest of the flow cannot work.
- Send: values found in the answer stay until you close the app, so you can send Create order and then Get order by hand. They appear next to the environment picker as Saved from answers, with Clear.
- Performance test: does not save values; it uses the ones saved by your last Send.
Test data
Feed rows from a CSV file into a request — many users, ids, or search terms instead of one.
- Test data → choose a CSV file (up to 5 MB). The first row names the columns; each column becomes a
{{variable}}, like{{email}}and{{password}}. - Use the variables anywhere in the request.
- Choose how rows are used during a performance test:
- In order — request 1 uses row 1, request 2 uses row 2, and so on, then starts again;
- Random — each request picks a random row;
- One row per user — each simulated user keeps its own row (good for logins).
Send and collection runs use the first row. The file's values are kept with the saved request; the report records only the file name and row count.
JSON bodies
Variables work inside JSON bodies too: { "email": "{{email}}" }. Values are inserted safely, so a quote or backslash in a value cannot break the JSON.