You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error: The 'filter' query option must be provided. #365
I'm sure some of the issues I'm seeing are a lack of understanding how this library works. I'm trying to understand the patterns that have to be in place, but when I run the following code I get this odd error that the Error: The 'filter' query option must be provided. and I don't understand why I have to pass a filter.
I find it very strange that several users, me included, have copied one of the few code samples in this repo, and it doesn't work. My conclusion so far is that it's a lot more clunky and hard to work with the Python SDK instead of doing requests directly to the Graph API. How can one find files by relative path for example? It seems like one needs to acquire the ids of every drive, site and item one wants to request, but that gets challenging when the code samples to get those ids don't work.
Andrew Omondi (@andrueastman) In the link you sent under this section, the HTTP tab correctly shows how to list files in the root of a drive. However, the Python tab is identical to the one in section "List children of a DriveItem with a known ID" that requires one to get a DriveItem id first. While there is no Python version for "known path".
More working code samples would be greatly appreciated.
Reacted by Guillaume Turcotte, wzhgoj, Matt LeMay, Mohammed Khalid Shaik, Christopher Warrick, parekhs-deshaw, Daniel and Brian Kim
Even better on my end: I get the same error, but when I pass in the $filter query param, although it now works, the queries actually have no effect, all items are returned.
Specifically, the method client.drives.by_drive_id('DRIVE_ID').items.get() in section 3. LIST ALL THE ITEMS IN A DRIVE is not working.
So instead, you can use the method from section 6. GET ITEMS IN THE ROOT FOLDER OF THE DRIVE: client.drives.by_drive_id('DRIVE_ID').items.by_drive_item_id('root').children.get()
Differences Between Methods
As I could not test on .items.get(). However, I believe:
.items.get() returns a FLAT LIST of ALL files and folders
.items.by_drive_item_id('root').children.get() returns only the children of the root folder.
Using .items.get() (will produce an error), I assume it is intended to return: File1.txt, Folder1, File2.txt, File3.txt
Using .items.by_drive_item_id('root').children.get(), it would return only: File1.txt, Folder1, File3.txt
(As File2.txt is in Folder1 not root)
If you still want to get a flat list of all drive items, you can use .items.by_drive_item_id('root').children.get() and then loop through all the found folders.
At least for now, this is the only solution I have come up with. Please let me know if there's a fix for this!
Activity
justmike1 commentedon Oct 19, 2023
hey, did you solve it? I am having the same issue
glinft commentedon Oct 24, 2023
Did you solve it?
I am having the same issue today.
stvpwrs commentedon Nov 14, 2023
No luck Mike J (@justmike1) and Glenn (@glinft). I don't think that code is actually valid, but it did appear in some samples at one point.
andrueastman commentedon Apr 3, 2024
Thanks for raising this Steve Powers (@stvpwrs)
The drive api does not support listing items from the
itemssegment.Any chance the documentation below is helpful?
https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http
kristianandre commentedon Aug 2, 2024
I find it very strange that several users, me included, have copied one of the few code samples in this repo, and it doesn't work. My conclusion so far is that it's a lot more clunky and hard to work with the Python SDK instead of doing requests directly to the Graph API. How can one find files by relative path for example? It seems like one needs to acquire the ids of every drive, site and item one wants to request, but that gets challenging when the code samples to get those ids don't work.
Andrew Omondi (@andrueastman) In the link you sent under this section, the HTTP tab correctly shows how to list files in the root of a drive. However, the Python tab is identical to the one in section "List children of a DriveItem with a known ID" that requires one to get a DriveItem id first. While there is no Python version for "known path".
More working code samples would be greatly appreciated.
venukalam commentedon Dec 4, 2024
This example in the docs is still outdated. It’s confusing and wasting a ton of people’s time.
pierremonico commentedon Dec 11, 2024
Even better on my end: I get the same error, but when I pass in the
$filterquery param, although it now works, the queries actually have no effect, all items are returned.alesposto commentedon Dec 12, 2024
Pierre Monico (@pierremonico) did you fix it? Can you explain what did you change? Ty
ThongLai commentedon Dec 30, 2024
I believe you followed the sample provided here: https://github.com/microsoftgraph/msgraph-sdk-python/blob/main/docs/drives_samples.md.
Specifically, the method
client.drives.by_drive_id('DRIVE_ID').items.get()in section 3. LIST ALL THE ITEMS IN A DRIVE is not working.So instead, you can use the method from section 6. GET ITEMS IN THE ROOT FOLDER OF THE DRIVE:
client.drives.by_drive_id('DRIVE_ID').items.by_drive_item_id('root').children.get()Differences Between Methods
As I could not test on
.items.get(). However, I believe:.items.get()returns a FLAT LIST of ALL files and folders.items.by_drive_item_id('root').children.get()returns only the children of the root folder.For example, with this structure:
.items.get()(will produce an error), I assume it is intended to return:File1.txt,Folder1,File2.txt,File3.txt.items.by_drive_item_id('root').children.get(), it would return only:File1.txt,Folder1,File3.txt(As
File2.txtis inFolder1notroot)If you still want to get a flat list of all drive items, you can use
.items.by_drive_item_id('root').children.get()and then loop through all the found folders.At least for now, this is the only solution I have come up with. Please let me know if there's a fix for this!