I am trying to save a token after a requests is made so I can refresh the env token variable each run. How do I save the token from the responses body into a env variable for use on other requests. I have this so far.
1 Like
use the below code as your test script
const responseJson = pm.response.json();
var bodyToken = responseJson.access_token;
pm.environment.set("bodyToken", bodyToken)
7 Likes
That worked beautifully, thank you!
1 Like
Once setting the variable, You can further get it with
pm.variables.get("bodyToken");
use it for further request for chaining
1 Like
This worked perfectly