Error when trying to read items from Sharepoint folder that containing more than 5000 files
Hi,
I'm trying to read files (e.g: filename, file content) from a Sharepoint folder that containing more than 5000 items.
Part of my code is shown below:
def get_filenames(self, relative_folder_url:str)->List[str]:
folder = self.context.web.get_folder_by_server_relative_url(relative_folder_url)
files = folder.files
self.context.load(files)
self.context.execute_query()
return [file.name for file in files]
However, no list has been created on my Sharepoint.
The items are children of a folder created inside the "Form" component (a folder in Shared Documents section).
Example of the folder url:
https://xxxxxxx.sharepoint.com/teams/yyyyyy/Shared%20Documents/Forms/AllItems.aspx?id=/teams/yyyyyy/Shared%20Documents/Terceira%20Versão/GDT or (it has the same response) https://xxxxxxx.sharepoint.com/teams/yyyyyy/Shared%20Documents/Terceira%20Versão/GDT
The code above works in any folder containing less than 5000 items. I've read about #558 and #392 but there it's about items from List resource. It's not my case. I don't use "self.context.web.lists".
How can I change the code to works with large folders (>5000) without works with List? I'm using the version 2.3.16.
Thanks in advance, Lucas.
Same here. I don't think I can fetch more than 5000 items (in my case files) with 2.3.14 method (I've tried 2.3.14 and 2.3.16).
page_size = 5000
files = folder.files.get_all(page_size, print_progress).execute_query()
gets up to 5000 files. If above only first 5000 is returned and others are missed. Is there any way around it?
BTW same with paged() method.
It seems it does only return first page_size amount of items. Others are ignored.
And when filecount exceedes 5000 I've got Microsoft.SharePoint.SPQueryThrottledException.
code:
page_size = 5000
files = folder.files.get_all(page_size, print_progress).execute_query()
folder has 31137 files according to
folder.storage_metrics.properties['TotalFileCount']
also experiencing the same issue. any solution?