Filtering on item name in Graph API call

Sam 20 Reputation points
2023-08-30T20:39:14.37+00:00

Hello,

I am trying to find details about a specific item in a SharePoint list named "My Reports". The following Graph request works:

https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MySite:/lists/My Reports/Items

But this requires me to then search through the contents of the "My Reports" list for the subsequent files and folders. I am looking for a way to apply the filter in the Graph API call rather than looping through the contents and doing the filtering in another programming language. I am hoping to do something similar to the following to locate the folder named "TestFolder":

https://graph.microsoft.com/v1.0/sites/mysite.sharepoint.com:/sites/MySite:/lists/My Reports/Items?$filter=parentReference.contentType.name eq TestFolder

This does not run. Is a way to add a filter on the item name using the filter parameter?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,447 questions
0 comments No comments
{count} votes

Accepted answer
  1. CarlZhao-MSFT 36,336 Reputation points
    2023-08-31T07:40:09.8166667+00:00

    Hi @Sam

    Yes, you can filter files based on item name.

    First list the root directory file set, and then filter according to the file name:

    GET https://graph.microsoft.com/v1.0/sites/{site id}/lists/{list id}/drive/root/children?$filter=name eq '{item name}'
    

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful