Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

Cannot list items in a library

Open WojciechBuda88 opened this issue 7 months ago • 0 comments

Hello,

i did find such code here in one of the issues:

from office365.sharepoint.client_context import ClientContext from office365.sharepoint.listitems.listitem import ListItem from office365.runtime.auth.client_credential import ClientCredential

list_title = "

" page_size = 5000 <p>site_url = "https://<tenant>.sharepoint.com/sites/<site_name>/" client_id = "zzzzz" client_secret = "xxxxx"</tenant></p> <p>creds = ClientCredential(client_id, client_secret) ctx = ClientContext(site_url).with_credentials(creds)</p> <p>def print_progress(items): """ :type items: office365.sharepoint.listitems.collection.ListItemCollection """ print("Items read: {0}".format(len(items)))</p> <p>large_list = ctx.web.lists.get_by_title(list_title) all_items = large_list.items.get_all(page_size, print_progress).execute_query()</p> <p>I did apply the code in Azure Databricks, and even thou I know the files are existing there, the result is: Items read = 0</p> <p>the script works fine, if i change a list_title to something non-existing, I will get error 404, so the location is fine.</p> <p>I want to point out, that when im in my SP library location "Shared Documents" ("Dokumenty" in polish), its address is: https://<tenant>.sharepoint.com/sites/<site_name>/Shared%20Documents/Forms/AllItems.aspx</tenant></p> <p>and when I open a file called '123.xlsx' at that locatoin, its address is: https://<tenant>.sharepoint.com/:x:/r/sites/<site_name>/_layouts/15/Doc.aspx?sourcedoc=%7B8B31F683-EF38-4597-89D9-8E5BA5E955CB%7D&file=123.xlsx&action=default&mobileredirect=true</tenant></p>

WojciechBuda88 avatar May 08 '25 11:05 WojciechBuda88