microsoft-graph-apipower-automateazure-ad-graph-api

How do I filter Microsoft Graph by odata.type


I am working in Power Automate to pull data from Microsoft Graph, specifically:

https://graph.microsoft.us/v1.0/deviceManagement/deviceCompliancePolicies

I need to filter the results to only show devices with an iOS/iPadOS platform. But there is no platform field in the results. There is, however, the oData Type:

"@odata.type": "#microsoft.graph.iosCompliancePolicy"

But when I try to filter by oData type, I get errors.

Invalid filter clause: The child type 'odata.type' in a cast was not an entity type. Casts can only be performed on entity types.

Can you filter by oData type?


Solution

  • After some trial and error, I found the answer myself.

    No, you cannot use @odata.type in the HTTP action either in the URI field or in the Queries.

    First, I used a Compose to get the Value from my HTTP action.

    Then, I used Parse JSON on the Compose.

    Then I had to use a Filter Array action where @odata.type is not equal to null.

    Then, I used a Filter Array action on THAT array where @odata.type contains "iosGeneralDeviceConfiguration".

    So, it's possible but there are several steps to make it work.