How to create a variable automatically increment by 1 after every request in postman

You’ll need to store the value in variable. (Collection or Environment).

You then update your request to use the variable value. {{variableName}}, similar to how you’ve got the random variable set.

In the Tests tab for the request, you will then retrieve the variable, increment it by one and then resave it.

let myVar = pm.collectionVariables.get("variableName");
myVar ++ // increment by 1
pm.collectionVariables.set("variableName", myVar);

Using variables | Postman Learning Center

1 Like