Reputation: 1906
I'm trying to search a item of a SharePoint list using Graph API & C#.
Able to get all the items in list with below GET request
https://graph.microsoft.com/v1.0/sites/myorganization.sharepoint.com,70e38521-b8bd-4008-98d3-f84721c55e0b,3338923b-2c65-45a9-bd70-941ac1345ca0/lists/24c9dc88-03f4-4aca-816c-acfcaf7b864d/items?expand=fields
How I could search for a particular item in this list like below.
Looking for GET request format. Really appreciate your help in advance.
Upvotes: 0
Views: 808
Reputation: 555
Unfortunately, most of the advanced queries are not available for SharePoint using the Graph API. They seem reserved for Entra ID. The best you can do is use the search endpoint if you are filtering on file name, as a property search will inevitably lead toward a manual search of each DriveItem.
This doc gives an example of using the search/query endpoint:
https://learn.microsoft.com/en-us/graph/search-concept-files
Notice the big red caution they put up regarding missing or removed functionality. I have not been able to get the search/query endpoint to work on SharePoint files past name searching, which is simpler using this endpoint:
https://learn.microsoft.com/en-us/graph/api/driveitem-search?view=graph-rest-1.0&tabs=http
What's even stranger is that sometimes you can get certain queries to work using a filter, while others do not. So, use the query endpoint at your own risk. Searching by name seems to work well using the search endpoint, but you may have trouble putting a filter on top of it when searching DriveItems in SharePoint.
I am currently working on a manual approach to this problem myself. If that interests anyone I may post an update with examples.
Upvotes: 0
Reputation: 3655
You could try to add the filter in the end of the request:
?expand=fields&filter=fields/TransactionRef eq '317690_92800'
Upvotes: 0