Skip to main content

Notifications

Power Automate - Using Connectors
Answered

'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON_autopilot')' is of type 'Object'. The result must be a valid array.

(0) ShareShare
ReportReport
Posted on by 16
Iam getting an error that says 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON_autopilot')' is of type 'Object'. The result must be a valid array. I am trying to process each element of a JSON object. I attached a screenshot of my flow as well as the schema for the parse JSON connector. Does anyone have any ideas what may be causing this?
 
 Screenshot 2023-10-17 154017.pngScreenshot 2023-10-17 154404.png
{
    "type""object",
    "properties": {
        "statusCode": {
            "type""integer"
        },
        "headers": {
            "type""object",
            "properties": {
                "Transfer-Encoding": {
                    "type""string"
                },
                "Vary": {
                    "type""string"
                },
                "Strict-Transport-Security": {
                    "type""string"
                },
                "request-id": {
                    "type""string"
                },
                "client-request-id": {
                    "type""string"
                },
                "x-ms-ags-diagnostic": {
                    "type""string"
                },
                "OData-Version": {
                    "type""string"
                },
                "Date": {
                    "type""string"
                },
                "Content-Type": {
                    "type""string"
                }
            }
        },
        "body": {
            "type""object",
            "properties": {
                "@@odata.context": {
                    "type""string"
                },
                "@@odata.count": {
                    "type""integer"
                },
                "@@odata.nextLink": {
                    "type""string"
                },
                "value": {
                    "type""array",
                    "items": {
                        "type""object",
                        "properties": {
                            "id": {
                                "type""string"
                            },
                            "groupTag": {
                                "type""string"
                            },
                            "purchaseOrderIdentifier": {
                                "type""string"
                            },
                            "serialNumber": {
                                "type""string"
                            },
                            "productKey": {
                                "type""string"
                            },
                            "manufacturer": {
                                "type""string"
                            },
                            "model": {
                                "type""string"
                            },
                            "enrollmentState": {
                                "type""string"
                            },
                            "lastContactedDateTime": {
                                "type""string"
                            },
                            "addressableUserName": {
                                "type""string"
                            },
                            "userPrincipalName": {
                                "type""string"
                            },
                            "resourceName": {
                                "type""string"
                            },
                            "skuNumber": {
                                "type""string"
                            },
                            "systemFamily": {
                                "type""string"
                            },
                            "azureActiveDirectoryDeviceId": {
                                "type""string"
                            },
                            "managedDeviceId": {
                                "type""string"
                            },
                            "displayName": {
                                "type""string"
                            }
                        },
                        "required": [
                            "id",
                            "groupTag",
                            "purchaseOrderIdentifier",
                            "serialNumber",
                            "productKey",
                            "manufacturer",
                            "model",
                            "enrollmentState",
                            "lastContactedDateTime",
                            "addressableUserName",
                            "userPrincipalName",
                            "resourceName",
                            "skuNumber",
                            "systemFamily",
                            "azureActiveDirectoryDeviceId",
                            "managedDeviceId",
                            "displayName"
                        ]
                    }
                }
            }
        }
    }
}
  • Verified answer
    Re: 'Apply_to_each_2' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON_autopilot')' is of type 'Object'. The result must be a valid array.

    Hi @Java_Uzumaki ,

     

    Please try this formula instead

    body('Parse_JSON')?['body']?['value']

      

    vbofengmsft_0-1697592200934.png

     

    Best Regards,

    Bof

     

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard

Featured topics