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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Creating Powerflow to ...
Power Automate
Answered

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

(0) ShareShare
ReportReport
Posted on 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 ?

Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    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.

  • NielsZegers Profile Picture
    11 on at

    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
    33,195 Most Valuable Professional on at

    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 at

    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. 

  • Verified answer
    Expiscornovus Profile Picture
    33,195 Most Valuable Professional on at

    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 at

    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 🙂

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
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard