how to filter a specific channel/folder in the drives/list/items using Graph API

obada tinawi 5 Reputation points
2023-12-17T15:32:13.9433333+00:00

I am listing all the items in a drive in order to get files and folder tree and the file id which are needed in my application.

Request:

https://graph.microsoft.com/v1.0/drives/{drive-id}/list/items?$select=webUrl

Example response:

{"webUrl": "https://wz68x.sharepoint.com/sites/Mark8ProjectTeam/Shared%20Documents/General/AAA.pptx"}

so this is mean the file is in the General channel.

but calling the previous request it retrieve all files and folder in response in that drive, with make it very slow with big response if the drive have many files. I want to only get a specific folder or a channel. by using filter but it doesn't work.
Ideal solution:

https://graph.microsoft.com/v1.0/drives/{drive-id}/list/items?$select=webUrl?$

is there a way to make the filter works or achieve the same result with a different method.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. obada tinawi 5 Reputation points
    2023-12-17T15:50:38.1366667+00:00

    Found a solution by calling the items instead of list items.

    https://graph.microsoft.com/v1.0/me/drives/{driveid}/items?$filter=contains(webURL,'Documents/General')
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.