sahilrajput.com

Learn postman

image

image

image

image

image

image

NOTE: Environment variables always override collection variables.

image

image

image

Beware Beware Beware that you must remove “Inherit Authorization” from the signin/login requests as shown in below screenshot otherwise your’ backend may intercept those requests badly. (WARNIN: In slasher it actually does).

image

var jsonData = pm.response.json();

// 1. setting in currently active environment (MOST COMMONLY NEEDED, Date: 28 May, 2023)
pm.environment.set("TOKEN1", jsonData.token);

// 2. setting collection variable
pm.collectionVariables.set("TOKEN1", jsonData.token);

// 3. setting globally
pm.globals.set("TOKEN1", jsonData.token);

image

image

image

image

image

image

image

image

image

image

image

Source Stackoverflow Answer: Click here

// Strip JSON Comments
if (pm?.request?.body?.options?.raw?.language === 'json') {
    const rawData = pm.request.body.toString();
    const strippedData = rawData.replace(
        /\\"|"(?:\\"|[^"])*"|(\/\/.*|\/\*[\s\S]*?\*\/)/g,
        (m, g) => g ? "" : m
    );
    pm.request.body.update(JSON.stringify(JSON.parse(strippedData)));
}

// To set Content-Type again (see the original stackoverflow answer's comment section):
// pm.request.upsertHeader({key: 'Content-Type', value: 'application/json'});

image

image

image

image

Click here

image

In slasher:

image

image