web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Power automate loop th...
Power Apps
Answered

Power automate loop through nested arrays

(0) ShareShare
ReportReport
Posted on by 37

Hello,

 

I'm not too familiar with arrays. I'm building a flow where I get students info through an HTTP GET action.
I parse JSON the returned data with the following schema:

 

{
    "type""object",
    "properties": {
        "code": {
            "type""integer"
        },
        "class": {
            "type""object",
            "properties": {
                "uuid": {
                    "type""string"
                },
                "name": {
                    "type""string"
                },
                "description": {
                    "type""string"
                },
                "locationId": {
                    "type""integer"
                },
                "source": {
                    "type""string"
                },
                "image": {
                    "type""string"
                },
                "classAsmIdentifier": {
                    "type""string"
                },
                "userGroupId": {
                    "type""integer"
                },
                "studentCount": {
                    "type""integer"
                },
                "students": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "id": {
                                "type""integer"
                            },
                            "name": {
                                "type""string"
                            },
                            "email": {
                                "type""string"
                            },
                            "username": {
                                "type""string"
                            },
                            "firstName": {
                                "type""string"
                            },
                            "lastName": {
                                "type""string"
                            },
                            "photo": {
                                "type""string"
                            }
                        },
                        "required": [
                            "id",
                            "name",
                            "email",
                            "username",
                            "firstName",
                            "lastName",
                            "photo"
                        ]
                    }
                },
                "teacherCount": {
                    "type""integer"
                },
                "teachers": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "id": {
                                "type""integer"
                            },
                            "name": {
                                "type""string"
                            },
                            "email": {
                                "type""string"
                            },
                            "username": {
                                "type""string"
                            },
                            "firstName": {
                                "type""string"
                            },
                            "lastName": {
                                "type""string"
                            },
                            "photo": {
                                "type""string"
                            }
                        },
                        "required": [
                            "id",
                            "name",
                            "email",
                            "username",
                            "firstName",
                            "lastName",
                            "photo"
                        ]
                    }
                },
                "deviceGroupId": {},
                "deviceCount": {
                    "type""integer"
                },
                "passcodeLockGracePeriod": {
                    "type""object",
                    "properties": {
                        "hours": {
                            "type""integer"
                        },
                        "minutes": {
                            "type""integer"
                        },
                        "raw": {
                            "type""integer"
                        }
                    }
                },
                "wallpaperId": {}
            }
        }
    }
}

 

I want to get the ID of every student. I've been struggling all afternoon to get to that data. Apply each actions gave me the error that  I've deleted everything after the PARSE JSON step because I was getting desparate 😛

Attaced you can find the for each step with a compose action. In the compose action inputs field I have this value: 

items('For_each')?['id']
 
To be really honest I don't know what I'm doing with all those nested arrays / objects (I hardly know the difference).
Help would be greatly appreciated.

 

applytoeach.png
error.png
Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @Michaelvds 

    The error code means the @outputs('Oarse_JSON_List_Of_Students')?['body']?['class']?['students'] return null in your side , it means it had not get any data from your json.

     

    You can try to use this code :

    body('Oarse_JSON_List_Of_Students')?['code']?['class']?['students']

     

    And you need to write this code in your side , the array is just around with '[' and ']'.

    For example , this is my test data:

    vyueyunmsft_0-1700617363503.png

    The [{"id":1}] is an array !   So you can try to use the Compose action to check if you can get the correct array you need in your flow .

    If this still can not help you solve the issue , you can share your sample json to me so that i can help you better.

     

    Best Regards,

    Yueyun Zhang

     

     

     

  • Michaelvds Profile Picture
    37 on at

    Hello,

    Thanks for your answer. I tried what you said but it still gives me the NULL error. So here is sample data that I'm working with:

     

    {
    "statusCode": 200,
    "headers": {
    "Date": "Wed, 22 Nov 2023 08:11:22 GMT",
    "Transfer-Encoding": "chunked",
    "Connection": "keep-alive",
    "Server": "nginx",
    "x-server-instance": "jsms-frontend-57f5d98894-pswv2",
    "Access-Control-Allow-Origin": "*",
    "Cache-Control": "must-revalidate, max-age=0, private",
    "Set-Cookie": "hash=7e4e664974647242c88337758aa4858a; expires=Thu, 21-Nov-2024 08:11:22 GMT; Max-Age=31536000; path=/; domain=jamfcloud.com; secure; HttpOnly",
    "X-Frame-Options": "DENY",
    "Strict-Transport-Security": "max-age=63072000; includeSubDomains;",
    "Content-Type": "application/json; charset=utf-8"
    },
    "body": {
    "code": 200,
    "class": {
    "uuid": "eeaf298f-6b41-4bdb-a1cb-6bc10fdafd0d",
    "name": "6A",
    "description": "Imported from Apple School Manager",
    "locationId": 13,
    "source": "MANUAL",
    "image": "",
    "classAsmIdentifier": "",
    "userGroupId": 37,
    "studentCount": 8,
    "students": [
    {
    "id": 299,
    "name": "Hanne Beek",
    "email": "hanne.beek@lln.test.be",
    "username": "hanne.beek",
    "firstName": "Hanne",
    "lastName": "Beek",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 300,
    "name": "Paulien Deer",
    "email": "paulien.deer@lln.test.be",
    "username": "paulien.deer",
    "firstName": "Paulien",
    "lastName": "Deer",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 305,
    "name": "Ceriel Verley",
    "email": "ceriel.verley@lln.test.be",
    "username": "ceriel.verley",
    "firstName": "Ceriel",
    "lastName": "Verley",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 306,
    "name": "Rob Hoog",
    "email": "robin.hoog@lln.test.be",
    "username": "robin.hoogewijs",
    "firstName": "Rob",
    "lastName": "Hoog",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 307,
    "name": "Milano Ver",
    "email": "milano.ver@lln.test.be",
    "username": "milano.ver",
    "firstName": "Milano",
    "lastName": "Ver",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 310,
    "name": "Rob Dele",
    "email": "rob.dele@lln.test.be",
    "username": "rob.dele",
    "firstName": "Rob",
    "lastName": "Dele",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 311,
    "name": "Yar Din",
    "email": "yar.din@lln.test.be",
    "username": "yar.din",
    "firstName": "Yar",
    "lastName": "Din",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 312,
    "name": "Mat Van",
    "email": "mat.van@lln.test.be",
    "username": "mat.van",
    "firstName": "Mat",
    "lastName": "Van",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    }
    ],
    "teacherCount": 2,
    "teachers": [
    {
    "id": 133,
    "name": "Sofie De Beer",
    "email": "sofie.debeer@testsample.be",
    "username": "sofie.debeer",
    "firstName": "Sofie",
    "lastName": "De Beer",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    },
    {
    "id": 134,
    "name": "Ines Lamp",
    "email": "ines.lamp@testsample.be",
    "username": "ines.lamp",
    "firstName": "Ines",
    "lastName": "lamp",
    "photo": "https://test.jamfcloud.com/application/views/default/assets/image/avatar/avatar.png"
    }
    ],
    "deviceGroupId": null,
    "deviceCount": 0,
    "passcodeLockGracePeriod": {
    "hours": 0,
    "minutes": 1,
    "raw": 60
    },
    "wallpaperId": null
    }
    }
    }

     

     

    Thanks a lot for your assistance. Greatly appreciated!

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    Hi , @Michaelvds 

    According to your json object , dose it the output of the json?

    You can try to use :

    body('Oarse_JSON_List_Of_Students')?['class']?['students']

     

    Or you may replace the body('Oarse_JSON....') to this above json return .

     

    Best Regards,

    Yueyun Zhang

  • Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    After the Parse JSON Action, insert a Select Action.

    CatSchneider_1-1700642951699.png

    CatSchneider_4-1700643341579.png

     

    In the From field, you'll need to enter the formula: @{body('Parse_JSON')?['class']?['students']}

    And in the Map field enter the formula: @item()?['id']


    When you run the flow this will be your output from the Select Action:

    CatSchneider_2-1700643016125.png

     

  • Michaelvds Profile Picture
    37 on at

    Hi,

    Thank you for your answer. I tried what you said but it still gives me the Null error.

     

    Michaelvds_1-1700644999415.png

     

     

    Michaelvds_0-1700644987260.png

     

  • Michaelvds Profile Picture
    37 on at

    Hi,

     

    Sorry I don't really understand what you're asking?

  • Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    Instead of using the Parse JSON Action, try swapping that out for the HTTP Request Body. I basically took what you had provided previously but just the body data, and dropped that into a compose action to simulate the HTTP Request, then did the Parse JSON action. Mayhap if you take it one step back, it will work...

    CatSchneider_0-1700645461464.png

     

    CatSchneider_1-1700645479132.png

     

  • Michaelvds Profile Picture
    37 on at

    Hi and thanks again. I tried that but it gives me the following error:

     

    Michaelvds_0-1700645929016.png

     

  • Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    hmm, ok... real quick... is the response that you posted here (Re: Power automate loop through nested arrays - Power Platform Community (microsoft.com)) the response directly from the HTTP Request Action or the Parse JSON Action?

  • Verified answer
    Cat Schneider Profile Picture
    488 Most Valuable Professional on at

    Wait a second... in the From Field did you select the body dynamic value, or did you select to enter a formula and enter: body('HTTP_Request_ActionName')?['class']?['students']?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard