Postman Cheatsheet

Photo by Possessed Photography on Unsplash

Tests

Set variable value based on API’s response

var apiResponse = pm.response.json();// We can use JavaScript String methods like below:
var offset = apiResponse.access_token.substring(4,9);
pm.environment.set("oathToken", apiResponse.access_token);
pm.environment.set("timerOffset", offset);
// Concatenate String
pm.environment.set("bucketId", "Y-" + offset);

Add Delay before executing next API in Postman Runner

setTimeout(()=> {
var apiResponse = pm.response.json();
pm.environment.set("oathToken", apiResponse.access_token);
}, 10 * 1000); // 10 second delay

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yuvraj Patil

Yuvraj Patil

Loves coding and enjoys learning new technologies. Website: https://.yuvrajpatil.com