Skip to content

Cannot list items in a library #963

@WojciechBuda88

Description

@WojciechBuda88

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 = "<title>"
page_size = 5000

site_url = "https://.sharepoint.com/sites/<site_name>/"
client_id = "zzzzz"
client_secret = "xxxxx"

creds = ClientCredential(client_id, client_secret)
ctx = ClientContext(site_url).with_credentials(creds)

def print_progress(items):
"""
:type items: office365.sharepoint.listitems.collection.ListItemCollection
"""
print("Items read: {0}".format(len(items)))

large_list = ctx.web.lists.get_by_title(list_title)
all_items = large_list.items.get_all(page_size, print_progress).execute_query()

I did apply the code in Azure Databricks, and even thou I know the files are existing there, the result is: Items read = 0

the script works fine, if i change a list_title to something non-existing, I will get error 404, so the location is fine.

I want to point out, that when im in my SP library location "Shared Documents" ("Dokumenty" in polish), its address is:
https://.sharepoint.com/sites/<site_name>/Shared%20Documents/Forms/AllItems.aspx

and when I open a file called '123.xlsx' at that locatoin, its address is:
https://.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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions