Problemns with repeat request

Describe the bug
I need to do multiple requests using JSON for my API changing the ID of request.
I have tried to create a loop of request using variables but did not have success.

Specifications of my test

Enviroment Name: Test

Enviroment Variables:

Variable: index
Initial value: 0
Current value: 0

Params have nothing.

Authorization is empty.

Headers

Key: Content-Type
Value: application/json

Body

{ “ID”: {{index}} }

Pre-request Script

pm.environment.set("index", String(parseInt(pm.environment.get("index"))+1));

Tests

if (parseInt(pm.environment.get("index")) < 10)
{
    postman.setNextRequest("API Address");
}
else
{
    postman.setNextRequest(null);
}

App information (please complete the following information):

  • Java Servlet.
  • Postman v7.6.0
  • Local machine: Windows 10; Server: Linux Ubuntu.

Thanks for helping.

Hi Lucas,

Welcome to community :wave:

I have attached a sample collection below which successfully makes repeated requests. Please take a look at it.
https://www.getpostman.com/collections/aa170b22547a79f39bda

Hope this helps.

2 Likes