How to pass data between test steps?
Retrieve pre-step data
Add the login request (Request 1) to the test scenario.
Add the query request (Request 2) to the test scenario.
The query parameter for Request 2 needs to include the token returned by Request 1. Click on the "magic wand" icon 
🪄
in the token field in the query parameters of Request 2 and select "Retrieve pre-step data".Choose Request 1 for data retrieval, select the response body, and use JSONPath to extract the token returned by Request 1, like 
$.token
.Click Insert, and you'll see 
{{$.2.response.body.token}}
inserted as the query param.Click the "Run" button in the Test scenario to successfully pass the data from Request 1 to Request 2.
Referencing pre-step data using variable syntax
{{$.2.response.body.token}}
from the previous text:{{variable}}
syntax. Instead, you should use pm.variables.get
to reference pre-step data. For example:
Syntax reference
Category | Function | Syntax Example |
---|---|---|
Request | URL | {{$.<step id>.request.url}} |
Path parameter | {{$.<step id>.request.pathParam.<field name>}} | |
Query | {{$.<step id>.request.query.<field name>}} | |
Header | {{$.<step id>.request.header.<field name>}} | |
Body (form) | {{$.<step id>.request.body.<field name>}} | |
Body (json) | {{$.<step id>.request.body.<field path>}} | |
Response | Body | {{$.<step id>.response.body.<field path>}} |
Header | {{$.<step id>.response.header.<field name>}} | |
Cookie | {{$.<step id>.response.cookie.<field name>}} | |
Loop | Element (array element in ForEach loop) | {{$.<loop step id>.element.<field path>}} |
Index | {{$.<loop step id>.index}} |
Use variables to pass data
Add the login request (Request 1) to the test scenario.
In the post processors of Request 1, add an "Extract Variable" action to extract 
Learn more about Extract variable.
$.token
as {{token}}
.Add the query request (Request 2) to the test scenario.
Reference the variable 
{{token}}
in the query parameters of Request 2.Click the "Run" button in the Test scenario to successfully pass the data from Request 1 to Request 2.