How to combine multiple responses from a collection run

Hello
Situation: We use a software that offers to create lots of boards with different security configuration settings. The software does not include a report feature which would allow us to retrieve a list of the boards and their configuration. However, the software offers an API which can be used to retrieve this info. Calls to the API are limited to 50 boards per run.

With the help of @michaelderekjones , I figured out how to create a collection, holding one request which loops through the collection and returns a set of GET responses – one response holds data for 50 boards.

My next question is: How do I combine all these responses into one big json file? I would hope there is a better way than pasting 1600/50=32 responses one by one.

You will need to parse the response for each iteration and store the relevant data in an collection or environment variable, which you will retrieve, add the current requests data, and then re-save.

Looking at your previous question, the response was similar to the following.

{
    "size": 4,
    "offset": 200,
    "limit": 4,
    "total": 1627,
    "data": [
        {
            "id": "uXjVNae- JQQ=",
            "type": "board",
            "name": "REDACTED"
        }
    ]
}

Therefore your records is in the data array.

You won’t need to loop through the array, you can use the JavaScript concat() function to join the two arrays together and then re-save over the top of the existing collection variable.

You will need to create an initial collection variable with a blank array to collate the responses.

When you retrieve the array, you will need to JSON.parse() it, and use JSON.stringify() when you re-save it or it will be treated as a string.

Thanks Mike. It looks plausible. I’ll need to make time to learn about the features you mention. It looks to me like it’s a more advanced task than I initially thought it would be.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.