odatamicrosoft-graph-apigraph-explorer

Using Graph API is it possible to filter items from a list/document library filtering by webUrl containing some text?


I'm able to get the items from a document library by querying the Graph like this:

https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{library-id}/items

And I get items back that look like the following:

enter image description here

Now I want to filter the results to get only items where the webUrl property contains the text '1808569'. So I change the query to:

https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{library-id}/items?$filter=contains(webUrl,'1808569')

And here is what I get back:

enter image description here

If filtering by webUrl not supported??


Solution

  • You can filter list items only by fields. Filtering by any property (even by id) is not supported.

    GET /v1.0/sites/{site_id}/lists/{list_id}/items?$expand=fields&$filter=fields/Title eq 'foo'
    

    Not sure what exactly your value 1808569 represents in your case but as an alternative you can try to create a custom column on the list with this value 1808569 and then filter items by this custom field

    GET /v1.0/sites/{site_id}/lists/{list_id}/items?$expand=fields&$filter=fields/CustomField eq '1808569'
    

    Filter by field may require header Prefer:HonorNonIndexedQueriesWarningMayFailRandomly