Save response to global variable for use with other queries

Hey @larry,

Something like this should work. Under the Tests tab, write:

pm.environment.set('savedResponse', JSON.stringify(pm.response.json()));

Then to access it in a subsequent request, you can use:

const saved = JSON.parse(pm.environment.get('savedResponse'));

in a script or you can just use normal variable syntax, such as {{savedResponse}} in other parts of the Request that support variable substitution.

Hope this helps.

Best,

Kevin

1 Like