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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Error - Apply to Each ...
Power Automate
Unanswered

Error - Apply to Each from Graph HTTP Request "...is of type 'Object'. The result must be a valid array"

(0) ShareShare
ReportReport
Posted on by 9

Hi folks,

 

I'm having trouble with a flow where I need to grab the members of an Azure AD group via Graph HTTP request, and add or remove to groups based on their attributes. I'm getting stuck at iteration through the JSON that Graph returns:

 

Griffco_0-1653950611183.png

 

Griffco_1-1653950650674.png


I've tried some suggestions from the community, such as running it through Parse JSON, but to no avail. Here's a snippet of what Graph is spitting out:

 

 

{
 "body": {
 "value": [
 {
 "@odata.type": "#microsoft.graph.user",
 "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
 "userPrincipalName": "joe@test.com",
 "onPremisesExtensionAttributes": {
 "extensionAttribute1": null,
 "extensionAttribute2": null,
 "extensionAttribute3": null,
 "extensionAttribute4": null,
 "extensionAttribute5": null,
 "extensionAttribute6": null,
 "extensionAttribute7": null,
 "extensionAttribute8": null,
 "extensionAttribute9": null,
 "extensionAttribute10": null,
 "extensionAttribute11": null,
 "extensionAttribute12": "ABC",
 "extensionAttribute13": null,
 "extensionAttribute14": "123",
 "extensionAttribute15": "XYZ"
 }
 }
 ]
 }
}

 

 

 
Any help is greatly appreciated!!

Categories:
I have the same question (0)
  • Verified answer
    MaryT0905 Profile Picture
    170 on at
    Re: Error - Apply to Each from Graph HTTP Request "...is of type 'Object'. The result must be a valid array"

    So you can't put the body in an apply to each loop.  

     

    what you need to do is look copy and paste the raw outputs of the your HTTP Request to a notepad.

     

    Next, edit your flow, add a compose step after your HTTP, pass the body of the HTTP step into the compose

     

    Then, add a Parse jason step.  Use the body of the compose as the input.  Then for the Schema, Copy and past that code that you put in the one note early. 

     

    After that you will be able to use the dynamic content from your http request.  

  • Griffco Profile Picture
    9 on at
    Re: Error - Apply to Each from Graph HTTP Request "...is of type 'Object'. The result must be a valid array"

    Thanks for the reply!  I gave this a try, but I'm getting the following error:

    ExpressionEvaluationFailed. The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['body']' is of type 'Null'. The result must be a valid array.

    Griffco_0-1653956584550.png


    It's strange because clearly the "value" array is populated, and there are no Null values. Any more ideas?


    Edit: the above shows my attempt for testing expression '@body('Parse_JSON')?['body']', but I've also tried expression '@body('Parse_JSON')?['body']?['value']'
  • MaryT0905 Profile Picture
    170 on at
    Re: Error - Apply to Each from Graph HTTP Request "...is of type 'Object'. The result must be a valid array"

    can you show a screenshot of the dynamic content values available after you parse the flow?

  • Griffco Profile Picture
    9 on at
    Re: Error - Apply to Each from Graph HTTP Request "...is of type 'Object'. The result must be a valid array"

    Certainly!  Here's everything below the HTTP. Also, I've removed the on premises attributes to help simplify this a bit, I've made sure to go back and update the schema, etc.

    Griffco_1-1653957106623.png

    Griffco_2-1653957126079.png

     

  • Griffco Profile Picture
    9 on at
    Re: Error - Apply to Each from Graph HTTP Request "...is of type 'Object'. The result must be a valid array"

    I think I got it!

    It was a couple of things - thank you for cleaning up my logic, first off. From there I generated the JSON schema based on what Compose spits out (it was one less object in JSON than what the raw Graph output was).

    I then put my on prem attributes back in, and it failed the schema check though I updated. Reason was because the JSON parser didn't like that some of the on prem attributes were null, so changing the schema from "type": "string" to "type": ["string", "null"] fixed that bit.

    I'll mark your answer as the solution since you lead me down the right path!

  • MaryT0905 Profile Picture
    170 on at
    Re: Error - Apply to Each from Graph HTTP Request "...is of type 'Object'. The result must be a valid array"

    can you try doing the same thing for the item?  I assume the values you are looking for are actually in the item.  Therefore if you parse the item now that you have parsed the inital json, you should get the dynamic content

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard