Hello @shepsims, welcome to the community!
I can help you get around the first problem that you’re facing regarding storing the PRIDs and using that to get the comments per PR using the second request.
I wrote this collection to help you around with some sample code:
https://www.getpostman.com/collections/4f4d45aadc1c9e0f9eaf
Step 1: We’ll be using the collection runner feature in Postman to get around this problem.
If you need to run it one request at one time manually then you can do that too by tweaking the logic a bit. I am sure you’ll get your head around that once you see the scripts inside the collection that I wrote.
Also, we need to build a control logic which will help us in determining when to stop and when to keep the collection running, so for that I have used the feature of environments and postman.setNextRequest
Step 2: You need to create a new empty environment (you can refer the docs as to how you can create a new environment).
Step 3: Import the collection that I gave the link to above (again - https://www.getpostman.com/collections/4f4d45aadc1c9e0f9eaf) and you can see that there are two requests inside, the first is to fetch the PRIDS and the second is to get comments for each PRID.
Now, what we are gonna do is something like this:
- Get all PRIDS
- Get comment for each PRID and write some logic around how you plan to use the comments.
Step 3: Launch the collection runner and make sure you select the new environment that we created just now.
Step 4: Run the collection and right now, it uses some sample data that I faked using the Postman Mocks
You’ll see that initially I get an array for 4 PRIds and the collection runner loops over each ID and gets the comment for the same.
This logic will run for n
number of PRIDs.
I have documented the Tests scripts of both the requests and I am hoping that by reading the docs and the comments and code, you’ll be able to get around this problem.
All in all, you need to just basically replace the endpoints that I wrote with the actual endpoints and build the request.
Next you can write your logic and get your work done!
If you’re stuck somewhere, let me know!
Happy to help
Edit: FYI we’ve also published a collection demonstrating this that you can fork and try for yourself here:
https://www.postman.com/postman/workspace/postman-answers/collection/9215231-25b72aab-2c6a-4941-832d-dd47e142ff2a?ctx=documentation