You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
mjmt
6 months agoHelpful | Level 5
(Python SDK API Help) Some folders are not listing
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.
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-DBDropbox 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.
- mjmtHelpful | 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 😁
- Здравко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.
- mjmtHelpful | Level 5
I did not try continue listing, and after implementing this it worked. Thank you!
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,885 PostsLatest Activity: 11 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!