Answer the question
In order to leave comments, you need to log in
How to make pagination using python when getting a list of files from onedrive?
Good afternoon!
I'm trying to get a list of all uploaded files in the onedrive cloud using a python script. Because there are a lot of files - pagination is needed. The example from the documentation ( https://github.com/OneDrive/onedrive-sdk-python) is not entirely clear. I try like this:
items = client.item(drive='me', id='F017355272BB81D4!23673').children.request().get() # папка с вложенными папками
for folder in items:
print(folder.name, folder.id)
files = client.item(id=folder.id).children.request().get() # список файлов в папке, выдает макс 200шт.
for file in files:
print(file.name)
next_page = onedrivesdk.ChildrenCollectionRequest.get_next_page_request(files, client).get() # получаю
for fl in next_page:
print(fl.name)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question