Hi,
I’m new one to Postman and trying to consider it as a mocking tool.
First thing I wasn’t able to use local variables in examples.
For instance:
request
{ "firstName": "John", "lastName": "Doe", "dob": "1990-01-01" }
script
const requestObj = JSON.parse(pm.request.body.raw); pm.variables.set('firstName', requestObj.firstName); pm.variables.set('lastName', requestObj.lastName);
example body
{ "id": "{{$guid}}", "firstName": "{{firstName}}", "lastName": "{{lastName}}" }
In fact only id is evaluated. Is it possible to use any variables in examples?
If yes, then next question is how to access history from scripts?
Means the second request will pass id (from previous one) as parameter and use data of previous request/response body in script to generate a new response?
Thanks!