Skip iteration based on value

I am working on a postman collection where I have written two get requests for APIs. I am using a single data file in the runner for both the requests when I run. My data file looks like below -

enter image description here

What I am trying to do is when I run request1 it should use Algo_id and use in the query parameter and for request2 it should use product_ids . When I run these request from the test runner using data file it runs the requests for the blank values as well, four requests each. I want to skip the runs for blank values and only run it when there is a value in the column for the request.

I want to run both the request two times and skip for the blank ones.

what I have tried so far, but had no success -

request1 Pre-request script -

enter image description here

request2 Pre-request script -

enter image description here

1 Like

image
Each line would constitute a run of your collection. If you place the values all in the same rows the
Run1 = request1(Algo_id :1210) , reqquest2(product_ids:β€œ04372173”)
Run2 = request1(Algo_id :33) , reqquest2(product_ids:β€œ00766001”)

This would result in what you are looking to accomplish I assume. If the calls interact with each other then there might be a different solution that you would need to do.

Hey @rohit,

Welcome to the community :wave:

Two ways you could accomplish this depending on how easy you’d like it to be:

The easiest way would be to split your Collection ( or create two separate folders in a collection one for Algo_id and another for product_ids ) and have two different data files and run each Collection/Folder using the relevant data file separately.

Another way to accomplish this, would be to create a third request that acts as a Dummy request just for branching purposes ( using setNextRequest as you have been doing ). This dummy request would un prior to your other two requests and just be used to set the conditions you’d like.

Hope this helps provide some guidance. Let us know if you still need help!

thanks, I will try this. I have however implemented the logic to skip the test instead whole request as I was trying. this way I let the request run but don’t test.

thanks, I will give it a try. I have however moved ahead with skipping the test based on the value, this way I let the request run but don’t run the tests.