How to convert value in a collection to array in a different structure

I really don’t know if I worded that right, but hopefully this explanation will do better :wink: I have a scenario where I’m using 1 operation and API call to fetch a list of IDs of Contact records in HubSpot. The output is like this:

"associations": {
            "contacts": [
                {
                    "id": "33031467392",
                    "type": "company_to_contact"
                },
                {
                    "id": "33031467392",
                    "type": "company_to_contact_unlabeled"
                }
            ]
        }

I then want to get extended property information of each of these IDs, but I’m trying to save ops, so I’d like to do a batch call to HubSpot, to get all of them in 1 operation. There is a Batch endpoint, but it expects the IDs to be fed to it in a particular format, like so:

 "inputs": [
    {
      "id": "12345"
    },
    {
      "id": "12345"
    }
  ]

Since this is a custom API call, it’s just a body parameter that I’m filling with this information:

Any pointers as to how I go from the one to the other, with as little operations as possible? I’ve been toying with creating or aggregating to JSON but so far haven’t been able to figure it out.

1 Like

Hi @Bob_Balm

After listing the associations, please use an iterator to iterate the “Contacts” array. Then use array aggregator and only select “id” from iterator. Then you map the array from aggregator in your api call.

Best regards,

Msquare Automation
Platinum Partner of Make
@Msquare_Automation

Hmm, I’m not sure if I’m doing it right. I now have this:

…which doesn’t help much because it’s the same structure that it already was (see screenshot in my OP) but minus the type.

I’m not sure what to enter in the red box to get the structure as pictured. I tried the map() function, but I don’t think that’s it. Any ideas?

Hi @Bob_Balm

Map the array from aggregator here instead of array after the “inputs” : [ ]
image

Best regards,

Msquare Automation
Platinum Partner of Make
@Msquare_Automation