Similar type situation I am facing also. I too have 3 requests . I want to run request A & B (A is GET, B is POST) on the pre request tab of request C. So that I can have necessary info to run request C. Problem I am facing is , when I run request C, B is running first and then A is running . That means POST is running first and then the GET. As a result I am unable to execute the request C.
This is my pre request script,
const getOTP = {
method: ‘GET’,
url: ${pm.environment.get('base_url')}/${pm.environment.get('common_path')}/otp-login?msisdn=${pm.environment.get('msisdnWhite')}
,
header: {
'User-Agent': 'something',
'Accept-Language' : 'en'
},
};
const postOTP={
method : 'POST',
url : `${pm.environment.get('base_url')}/${pm.environment.get('common_path')}/otp-login`,
header: {
'Content-Type':'application/json',
'Accept-Language':'en'
},
body:{
mode : 'application/json',
raw: JSON.stringify(
{
"msisdn":"12345666666",
"otp":"0000"
} )
}
};
pm.sendRequest(getOTP, (err, response) => {
const jsonResponse = response.json();
pm.environment.set(“GETOTP”,jsonResponse.result)
console.log(jsonResponse);
});
pm.sendRequest(postOTP, (err, response) => {
const jsonData = response.json();
pm.environment.set("access_token",jsonData.access_token)
});
Any help is much appreciated. Thanks in advance.