1

I'm trying to access the values in JSON output that I received from two (2) Graph API calls, but each time I try to use them I get this error:

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

I have validated that my Graph API calls are properly formatted, and output is exactly what I'm expecting to be returned from both API calls. I get this error every time I either try to access the parsed JSON in an Azure Runbook or any other Logic App tasks.

I would love to know if someone has experienced this before and how it can be solved?

Graph query: https://graph.microsoft.com/beta/deviceManagement/managedDevices/?$select=id,userId,deviceName,userDisplayName,azureADDeviceId,managedDeviceName,emailAddress&$filter=operatingSystem eq 'windows'

JSON schema for managed devices

 {
 "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"

}

Graph query: https://graph.microsoft.com/beta/users?$select=id,displayName,mail,officeLocation&$filter=accountEnabled eq true

JSON schema used for 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"

}

defen
  • 15
  • 1
Omar Davis
  • 11
  • 1
  • Hello, if the answer is helpful, could you please [accept](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) it as answer(click on the check mark beside my answer to toggle it from greyed out to filled in)? Thanks. It may help others. – Frank Borzage May 10 '21 at 06:02

0 Answers0