Cheatsheet — Postman

Yuvraj Patil
Jul 30, 2022
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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Yuvraj Patil
Yuvraj Patil

Written by Yuvraj Patil

Riding the dragon in realm of React Native. Website: https://.www.yuvrajpatil.com

No responses yet

Write a response