I am trying to hit a particular API, which actually send the OTP to customers, their is not Rate Limiter is their on this API, So I am trying to write a pre-request script that will run multiple times, in which I pass the two numbers in the code given below, but main problem is it is not working for the two numbers, it takes only one number which is I pass in the body of the postman which is in JSON format, it doesn't go in the script, please help me to solving this
Postman Request Type : POST
API URL : http:// (API URL)
Body :
{"mobile_number":"94XXXXXXXX","template":"login","countryCode":"91"}
Pre-request Script:
var mobiles = postman.getEnvironmentVariable("mobiles");
if (!mobiles)
{
mobiles =["88XXXXXXXX","80XXXXXXXX"];
}
var currentMobile = mobiles.shift();
postman.setEnvironmentVariable("mobile", currentMobile);
postman.setEnvironmentVariable("mobiles", mobiles);
Tests:
var mobiles = postman.getEnvironmentVariable("mobiles");
if (mobiles && mobiles.lenght > 0)
{
postman.setNextRequest("API URL");
}
else
{
postman.setNextRequest("null");
}
P.S : I am not sharing the API url here, and the mobile number . Sorry for that