A
A
Artem2018-02-26 12:18:24
Python
Artem, 2018-02-26 12:18:24

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)

but I only get 1 next page, not all possible ones. How can I get all pages with files?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question