cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more right here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: (Python SDK API Help) Some folders are not listing

(Python SDK API Help) Some folders are not listing

mjmt
Helpful | Level 5

I am writing a helper app with the python sdk to iterate through folders within a team folder and add certain child folders within specific folders that have a name matching a list of names I have.

 

So far I am able to iterate through the folders and match the specific folders I want, but some of the folders seem to indiscriminately not be selected from my parent folder which makes it impossible for me to automate this task because of the risk of creating redundant folders. 

 

Here is some of my code:

 

 

 

 

names = [] # contains 100 strings of the folder names I need to match or create a folder for if not matched

# connect to dropbox
dbx = dropbox.Dropbox('access token')

# configure team space
# ref : https://stackoverflow.com/questions/75561322/dropbox-python-api-team-folder-access
root_namespace_id = dbx.users_get_current_account().root_info.root_namespace_id
dbx = dbx.with_path_root(dropbox.common.PathRoot.root(root_namespace_id))

for folder in dbx.files_list_folder('/my/path/', recursive=False).entries:
    # certain folders in here are just not being listed when I check with:
    # print(folder.name)
    for name in names:
        if name in folder.name or folder.name in name:
            match.append(folder)
            # working for the folders that are listed

 

 

 

 

why does

 

 

 

 

for folder in dbx.files_list_folder('/my/path/', recursive=False).entries:

 

 

 

 

not list every folder in the parent folder? 


I initially thought it was only not listing folder when the "Who can access" column was listed as "Parent + others", however it seems to not list folders that are only "Parent" accessible as well. 

 

I should note, there are 852 folders I am trying to query from and the total amount of folders I am getting is 500 from my for loop. Is this a built in constraint?

Any help would be greatly appreciated.

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20

Hi @mjmt,

As seems, you observe only the first page of your list. Did you try continue listing? Keep in mind that list metadata are provided on pieces and every piece size is NOT guarantead (despite controlable). You have to check for more results waiting and continue when needed. Don't rely that entire list will get back as an only page (in spite possible)!

Hope this claryfies matter.

View solution in original post

4 Replies 4

Здравко
Legendary | Level 20

Hi @mjmt,

As seems, you observe only the first page of your list. Did you try continue listing? Keep in mind that list metadata are provided on pieces and every piece size is NOT guarantead (despite controlable). You have to check for more results waiting and continue when needed. Don't rely that entire list will get back as an only page (in spite possible)!

Hope this claryfies matter.

Greg-DB
Dropbox Staff

@mjmt Здравко is correct; it appears you are only calling files_list_folder, but that is not guaranteed to return everything. You should implement both files_list_folder and files_list_folder_continue. Refer to the documentation linked there for more information on how to use that.

mjmt
Helpful | Level 5

I did not try continue listing, and after implementing this it worked. Thank you!

mjmt
Helpful | Level 5

Yes they are correct. I ended up just using the cursor to continue listing and that got all my queries. My program is now up and running 😁

Need more support?