Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
Looping until next request has number of results greater than 0 in postman

I am trying to find a proper way in postman to iterate between 2 requests until certain criteria is matched.

I have a GET /categories request where it gives you bunch of categories and I have another request Get /PLP. However in certain cases PLP get empty list making tests to failed because categories we store in variable is empty.

The thing I was trying was on /GET PLP requests, in pre-requisite script I am sending GET PLP request and checking if it is empty or not, if its empty I was setting postman.setNextRequest("Categories") so that it loops around until PLP is not empty. However this is not working for me. Has anyone have any idea how to solve it or have different approach. Below is my prerequisite script

var jsonData;

pm.sendRequest({
    url: pm.environment.get('url') + "categories=" + pm.environment.get('subCategoryId'),
    method: 'GET',
    header: {
        'content-type': 'application/json', 
    }
}, function (err, response) {
    if (err) throw new Error(err);
     var jsonData = response.json().numberOfItems;
     console.log(jsonData)

});

if (jsonData == 0) {
    postman.setNextRequest("Categories");
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!