1
votes

The following filter clause does not work in the Graph Explorer

https://graph.microsoft.com/v1.0/drives?$filter=name eq 'Documents'

Are there any limitations in the application of filters as the specified filter is as per OData protocol

2

2 Answers

1
votes

OneDrive API (and Graph API on drives) do not support filtering or ordering results. When Microsoft Graph sees a query parameter it doesn't expect, it simply ignoring the unknown filter parameter and returning us an unfiltered result. The drives api supports the $expand, $select, $skipToken, $top, and $orderby(orderby does not work on my side) OData query parameters to customize the response.

My test data: https://graph.microsoft.com/v1.0/drives?$filter=name eq 'Documents'/$filter=driveType eq 'documentLibrary'":

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives",
    "value": [
        {
            "createdDateTime": "2018-06-04T07:32:28Z",
            "description": "List of all app packages uploaded in the Dev Site",
            "id": "b!NEuoD0E0IkyGzigmyNtKyXtJFUgDWoBJhM2BFIAvNsp69o2q1-czTaV6INjgi_dk",
            "lastModifiedDateTime": "2018-06-05T04:19:59Z",
            "name": "App Packages",
            "webUrl": "https://xxxx.sharepoint.com/Lists/AppPackages",
            "driveType": "documentLibrary",
            "createdBy": {
                "user": {
                    "displayName": "System Account"
                }
            },
            "quota": {
                "deleted": 0,
                "remaining": 0,
                "total": 0,
                "used": 0
            }
        } 
    ]
}
0
votes

Seems with the newer version you can use FileName or FileType search https://docs.microsoft.com/en-us/microsoft-365/compliance/keyword-queries-and-search-conditions?view=o365-worldwide#searchable-site-properties

{"requests":[{"entityTypes":["microsoft.graph.driveItem"],"query":{"query_string":{"query":"fileextension:xlsx"}},"from":0,"size":25}]}