Skip to main content
Community site session details

Community site session details

Session Id : pP5JKjyAnKWDYu/NzTX60D
Power Automate - Building Flows
Answered

Creating Powerflow to detect Autopilot sync status - String to Array error

Like (0) ShareShare
ReportReport
Posted on 22 Jul 2021 09:28:12 by 11

I'm trying to create a Power Automate Flow to get the sync status and report us via email about it. But when I created the flow and tested it, I run into an error:

 

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

 

This is the specific flow:

22-7-2021 11-24-59.png

But at testing I get an error at the "Apply to each 2" step:

22-7-2021 11-25-53.png

 

I can understand the input of the data is in "string" type, but I would like to have an email send when the "syncStatus" is in a specific status. And apparently I have to convert it into an array.

 

Any tips or tricks on how to accomplish this ?

  • NielsZegers Profile Picture
    11 on 05 Aug 2021 at 07:55:04
    Re: Creating Powerflow to detect Autopilot sync status - String to Array error

    Hi @Expiscornovus,

     

    I've just replaced the JSON parse action with the expression. This seems to work and provide us with the necessary info. 

    Thanks for the tip and your efforts 🙂

  • Verified answer
    Expiscornovus Profile Picture
    32,169 Most Valuable Professional on 05 Aug 2021 at 07:48:22
    Re: Creating Powerflow to detect Autopilot sync status - String to Array error

    Hi @NielsZegers,

     

    I just had a look at that method in the Graph API, https://docs.microsoft.com/en-us/graph/api/intune-enrollment-windowsautopilotsettings-get?view=graph-rest-beta

     

    I think you are right. It will only give you back the status (and some additional supporting fields), that is one result.

     

    So, you can avoid the apply to each. And with an expression you can even avoid the parse json action.

     

    body('Get_Autopilot_sync_status')?['syncStatus']

     

    getautopilotsyncstatus.png

  • NielsZegers Profile Picture
    11 on 05 Aug 2021 at 06:53:15
    Re: Creating Powerflow to detect Autopilot sync status - String to Array error

    Hi @Expiscornovus,

     

    Thanks for the reply. This is the JSON schema:

    {
     "type": "object",
     "properties": {
     "@@odata.context": {
     "type": "string"
     },
     "id": {
     "type": "string"
     },
     "lastSyncDateTime": {
     "type": "string"
     },
     "lastManualSyncTriggerDateTime": {
     "type": "string"
     },
     "syncStatus": {
     "type": "string"
     }
     }
    }

     

    I retrieved the schema info by performing the following command in Microsoft Graph:

    Get https://graph.microsoft.com/beta/deviceManagement/windowsAutopilotSettings 

    This produces the schema I listed above.

     

    So I have done some more reading. If I understand correctly, this schema just gives back one result. So with one result you can't perform a "do for each" because there are no more results than just one. 

  • Expiscornovus Profile Picture
    32,169 Most Valuable Professional on 29 Jul 2021 at 09:02:04
    Re: Creating Powerflow to detect Autopilot sync status - String to Array error

    Hi @NielsZegers,

     

    Can you share your parse json schema? I am interested to see what type of fields you are using.

     

    Have you tried combining the status and mail to fields in the condition with an AND?

     

    condition_and.png

  • NielsZegers Profile Picture
    11 on 29 Jul 2021 at 08:47:08
    Re: Creating Powerflow to detect Autopilot sync status - String to Array error

    Hello @Expiscornovus,

     

    The reason why I wanted to to an "apply to each" is that we have a "mail to" action with a specific value from the JSON reply. For example is the value is "TRUE" we want to have an email send and if the value is "FALSE" no email.

     

    I have tried to place a condition to check the status, but from every reply (value) we get (either TRUE or FALSE) an email is being send. 

  • Expiscornovus Profile Picture
    32,169 Most Valuable Professional on 22 Jul 2021 at 15:30:09
    Re: Creating Powerflow to detect Autopilot sync status - String to Array error

    Hi @NielsZegers,

     

    Just to double check. Is there a reason why you are using an apply to each action?

     

    It looks like sync status is a string and not an array. I would place a condition to check for the status directly after the parse json action and get rid of the apply to each.

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

Announcing our 2025 Season 2 Super Users!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 2

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 2

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 2

Loading complete