Problem with running a collection - only first request runs

Hello all.

I am running a collection of two requests.
The first one of them is using a data set in the following way:


Json Body:

{
“cloud”: “dummy-cloud”,
“virtual_network”: “123”,
“group_type”: “scaling”,
“scaling_group”: “dummy_scale_group_1”,
“availability_group”: “None”,
“server_addresses”: ,
“server_subnet”: ,
“fqdns”: “None”,
“selection_metric”: “{{cur_val}}”,
“health_check”: “http”,
“name”: “sg1”
}


prerequest script:

var values = pm.environment.get(“values”);

if(!values)
values = [“val1”, “val2”, “val3”];

var cur_val = values.shift();
pm.environment.set(“cur_val”, cur_val);
pm.environment.set(“values”, values);


and the tests part:

var conn_metrics = pm.environment.get(“conn_metrics”);

if(values && values.length > 0)
postman.setNextRequest(“Update Server Group”);
else
postman.setNextRequest(null);



The problem is that only the put requests are being executed and the Get requests aren’t.

Why?

Thank you!

1 Like

Me too got struck in the same problem. Appreciate for any help!!!

The code in the pre-request script where you initialize values does not get shared with the test script where you have the if with values.

Use console.log to debug your code.

1 Like

I have checked in console and am not able to find the origin of issue. Can you please specific on that? sharing the above code by correction would be much appreciated.

Please share your collection.

will share with ur personal email as it has confidential information.