I'm trying to use Logic Apps to create an automation around Azure AD managed devices. I have two Graph API calls which are executed via a HTTP requests that return the desired results. I then parses these objects as a JSON file using the schema shown below. However, whenever I try to manipulate the JSON objects I get the following error:
ExpressionEvaluationFailed. The execution of template action 'For_each' failed: the result of the evaluation of 'foreach' expression '@Tomas Podoba ('Parse_JSON_-_Managed_Devices')?['body']?['value']' is of type 'Null'. The result must be a valid array.
JSON to get all managed devices
Graph query: https://graph.microsoft.com/beta/deviceManagement/managedDevices/?$select=id,userId,deviceName,userDisplayName,azureADDeviceId,managedDeviceName,emailAddress&$filter=operatingSystem eq 'windows'
{
"properties": {
"body": {
"properties": {
"@@odata.context": {
"type": "string"
},
"@@odata.count": {
"type": "integer"
},
"@@odata.nextLink": {
"type": "string"
},
"value": {
"items": {
"properties": {
"azureADDeviceId": {
"type": "string"
},
"deviceName": {
"type": "string"
},
"emailAddress": {
"type": "string"
},
"id": {
"type": "string"
},
"managedDeviceName": {
"type": "string"
},
"userDisplayName": {
"type": "string"
},
"userId": {
"type": "string"
}
},
"required": [
"id",
"userId",
"deviceName",
"userDisplayName",
"azureADDeviceId",
"managedDeviceName",
"emailAddress"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
}
JSON to get all users
Graph query: https://graph.microsoft.com/beta/users?$select=id,displayName,mail,officeLocation&$filter=accountEnabled eq true
{
"properties": {
"body": {
"properties": {
"@@odata.context": {
"type": "string"
},
"@@odata.nextLink": {
"type": "string"
},
"value": {
"items": {
"properties": {
"displayName": {
"type": "string"
},
"id": {
"type": "string"
},
"mail": {
"type": "string"
},
"officeLocation": {
"type": "string"
}
},
"required": [
"id",
"displayName",
"mail",
"officeLocation"
],
"type": "object"
},
"type": "array"
}
},
"type": "object"
}
},
"type": "object"
}
I would love if someone could help point me in the right direction.
Thanks in advance.