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:
But at testing I get an error at the "Apply to each 2" step:
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 ?
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 🙂
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']
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.
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?
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.
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.
Michael E. Gernaey
497
Super User 2025 Season 2
David_MA
436
Super User 2025 Season 2
Riyaz_riz11
244
Super User 2025 Season 2