Efie
Efie

Reputation: 1680

Microsoft Graph API odata $filter query does not appear to work

I am trying to filter a set of data returned by the MS Graph API's managedDevices endpoint using an odata filter.

Sending the request without a filter gets the expected result.

GET https://graph.microsoft.com/beta/deviceManagement/managedDevices

returns this response:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#deviceManagement/managedDevices",
    "@odata.count": 5,
    "value": [
        {
            "id": "kj23kj4-0d47-34f3-8ff0-6b5sdfsdf3332f",
            "userId": "asdfasw-1b48-436d-aa42-3werwer2344",
            "deviceName": "some_device_name_9/16/2020_6:31 PM"
            ...

When I send any of the following requests I get the exact same response with 5 results:

GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=id eq 'kj23kj4-0d47-34f3-8ff0-6b5sdfsdf3332f'
GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=id in ('lksjdf...','qwerqwer...')
GET https://graph.microsoft.com/v1.0/deviceManagement/managedDevices?$filter=ownerType ne 'personal'

I didn't see this listed on uservoice as an issue others are having specifically. They also apparently don't explicitly call out what odata query params are and aren't supported for specific endpoints. $select, for example, does work on this endpoint.

Upvotes: 1

Views: 2309

Answers (1)

Hury Shen
Hury Shen

Reputation: 15724

For this problem, I test it in my side also can't do the filter. And the odata url is correct, so I think the field id just not be designed to do filter.

If you want to do filter with id, you can use https://graph.microsoft.com/v1.0/deviceManagement/managedDevices/{id} directly. It can get the result with specific "id", maybe it is why the field id not be designed to do filter.

Upvotes: 1

Related Questions