How to create a collection of GET requests with nested loops and download the data from the nested loop

Hello,

I am fairly new to Postman and need to create a collection of GET requests that:

  1. Gets a list of Buildings
  2. Loops through the array of Buildings and for each Building, finds the Floors
  3. Loops through the array of Floors and for each Floor, finds the Spaces on that Floor
  4. Loops through the array of Spaces and for each Space, gets different attributes such as Area, Created Date, Interior/Exterior, Occupant, Entry Time In, Entry Time Out, etc for a date range
  5. Download all these Space attributes data and upload them to a SQL Server DB.

My GET request for the list of Buildings works ok and I have them in an array.

When I loop through the Buildings array to find the Floors, I am unable to stop the processing once all the values of the array are done.

Also, in my GET request for finding Spaces, the Building ID from the very first GET request is lost. So no other processing happens.

For some reason, the Postman.setNextRequest function fails.

Any help/advise would be very appreciated!

Thanks much!!
AG