cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
colonel_claypoo
Level: Powered On

How to access each item in JSON array?

Hi,

I have an HTTP action that returns a maximum of 400 results per call. In order to collect all available items I'm storing each call's results in an array variable.

 

For example, the total results count is 423. This means I have to execute the HTTP action twice to get all items. However, if I check with the length() expression it will show an array length of 2. the first array contains 400 JSON objects and the second one the remaining 23. 

 

My problem is that I'm unable to work with all 423. I've tried "Apply to each", "Select", "Parse JSON" but none gives me individual JSON objects to work with.

 

Here's the JSON schema, imagine that I have 423 times of what that is included in "value":

 

{
    "type": "object",
    "properties": {
        "odata.metadata": {
            "type": "string"
        },
        "value": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "Identity": {
                        "type": "string"
                    },
                    "AuditData": {
                        "type": "string"
                    },
                    "CreationDate": {
                        "type": "string"
                    },
                    "IsValid": {
                        "type": "boolean"
                    },
                    "ObjectState": {
                        "type": "string"
                    },
                    "Operations": {
                        "type": "string"
                    },
                    "RecordType": {
                        "type": "string"
                    },
                    "ResultCount": {
                        "type": "integer"
                    },
                    "ResultIndex": {
                        "type": "integer"
                    },
                    "UserIds": {
                        "type": "string"
                    },
                    "ObjectIds": {},
                    "IPAddresses": {},
                    "SiteIds": {}
                },
                "required": [
                    "Identity",
                    "AuditData",
                    "CreationDate",
                    "IsValid",
                    "ObjectState",
                    "Operations",
                    "RecordType",
                    "ResultCount",
                    "ResultIndex",
                    "UserIds",
                    "ObjectIds",
                    "IPAddresses",
                    "SiteIds"
                ]
            }
        },
        "odata.nextLink": {
            "type": "string"
        }
    }
}

So, "Apply to each" only applies to the two arrays - not getting the individual JSON objects.

"Select" doesn't work because it's not compatible with the array where the results are stored in.

Using "Parse JSON" again also doesn't give me individual JSON objects to work with.

 

Any idea how I can access them?

Perhaps it's not smart to collect the HTTP action results in an array variable or they have to be filtered beforehand, i.e. narrowed down to the individual "value" JSON objects?

 

Thanks for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to access each item in JSON array?

Hi @colonel_claypoo,

 

Please share a screenshot of the HTTP response, if it returns an array with two sub-array, maybe you can use two Apply to each structure:Annotation 2019-09-27 153757.png

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Dual Super User
Dual Super User

Re: How to access each item in JSON array?

Hi @colonel_claypoo 

 

Can you share the response JSON

Community Support Team
Community Support Team

Re: How to access each item in JSON array?

Hi @colonel_claypoo,

 

Please share a screenshot of the HTTP response, if it returns an array with two sub-array, maybe you can use two Apply to each structure:Annotation 2019-09-27 153757.png

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

colonel_claypoo
Level: Powered On

Re: How to access each item in JSON array?

That worked. Did this in an do...until action to also check when there're no more rsults to be retrieved. Thanks for the pointer.

Helpful resources

Announcements
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,337)