Friday, February 21, 2020

POSTMAN - How to use random number in the request

Just use the variable randomInt, for example:
In the request:
{
    "id": "{{$randomInt}}"
}

In the pre-request Script:
postman.setEnvironmentVariable("myId", "MY_ID_"+ _.random(1,99999));
console.log(postman.getEnvironmentVariable("myId"));
Read this link for more information: https://learning.postman.com/docs/postman/variables-and-environments/variables/

No comments:

Post a Comment