Filtering on @odata.type via Microsoft Graph API

This is a knowledgebase item. Hope it helps you out someday with filtering on @odata.type.

To get a subset of the results from the Graph API, we can use the filter command. The $filter query parameter can also be used to retrieve relationships like members, memberOf, transitiveMembers, and transitiveMemberOf.

More information about filters can be found here.

Filtering Error on @odata.type via Graph API

Filtering works fine for almost all properties, but if you want to filter by the @odata.type, for example, it’s just a little bit different. In my case, I wanted to filter on @odata.type because I only needed all profiles from a specific policy type for my PowerApp. So I have read the Microsoft documentation and started by applying the filter option. As you can see in the below Print screen it wasn’t working.

Solution

After a lot of troubleshooting I was lost but still I was convinced that it would be possible to filter by @odata.type. I opened the Endpoint Manager portal and opened my developer tools in de the browser. Click on some blades and checked the requested GRAPH URLs. One of the URLs contained the filter with ISOF, so I tried ?$filter=(isof(‘#microsoft.graph.windows10CustomConfiguration’)), but this wasn’t working. So let’s try without a hashtag. And suddenly I got my required profiles for my PowerApp.

https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?$filter=(isof('{odata type}'))

For e.g.,

https://graph.microsoft.com/v1.0/deviceManagement/deviceConfigurations?$filter=(isof('microsoft.graph.windows10CustomConfiguration'))

Results:

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.