Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
GopalN
6 years agoExplorer | Level 4
Not able to get team folders or files using python sdk
Python SDK,
Not Able to get files and folders
where I'm using dropbox business API access token
output = dbx.DropboxTeam(_dropbox_token).as_admin(ng_member_id).files_list_folder("").entries
print(output)
Trying this as suggested from the doc.
help me to do it
Trying to get files from a folder of folders and download the files.
What is the value of your '_team_name_space_id' variable?
Based on the error output you shared, if you want to list the contents of the team space, you should set your '_team_name_space_id' variable to "5632093280".
17 Replies
Replies have been turned off for this discussion
- phermans5 years agoExplorer | Level 3
Greg-DB Thanks again! Yes it helped a lot. I accidentally forgot to include the dbmid: part......silly me. I really appreciate your help. I will give it a go a bit later today and hopefully make more progress.
Thanks again!
- phermans5 years agoExplorer | Level 3
Greg-DB , I got that part working, but don't totally understand one part, hoping I missed it in the docs somewhere, or that there is a simple explanation. In the code you posted, there was both a for loop and a while loop...
for entry in listing.entries: print(entry.name) while listing.has_more: listing = dbx_admin_team_root.files_list_folder_continue(listing.cursor) for entry in listing.entries: print(entry.name)Not sure I understand why i need both of those. Seems like the initial for loop only gets some of the folders/files.....then the while keeps asking for more....but if that is correct, why even bother with the first for loop, why not just use the while listing.has_more loop? Wouldn't that just keep going until all the files/folders were returned, and in this case, had their names printed?
Thanks for clarifying.
- Greg-DB5 years ago
Dropbox Community Moderator
phermans In order to scale to folder listings of any size, the list_folder interface is paginated. The API may return the results across multiple pages, and each page can contain multiple files/folders. You need to implement calls to both files_list_folder and files_list_folder_continue to make sure you can receive all of the entries.
The first for loop iterates over the results on the first page, from files_list_folder; the while loop then has the app make additional calls to files_list_folder_continue as needed, and the second for loop iterates over the results from those subsequent pages, if any, from files_list_folder_continue.
Check out the files_list_folder documentation for more information on using this functionality.
- mukesh1114 years agoNew member | Level 2output = dropbox.DropboxTeam(TOKEN).with_path_root(dropbox.common.PathRoot.root(team_space_namespace_id)).as_admin(member_id).files_list_folder("").entries
what is the team_space_namespace_id here? I use a 10-digit number
Traceback (most recent call last):
File "/home/mukesh/Documents/automation/app_test/dropbox/test_dropbox.py", line 20, in <module>
output = dropbox.DropboxTeam(TOKEN).with_path_root(dropbox.common.PathRoot.root(team_space_namespace_id)).as_admin(member_id).files_list_folder("").entries
File "/home/mukesh/Documents/BOVIWALK/projects/pose_estimation/boviwalk-ai/venv/lib/python3.10/site-packages/dropbox/base.py", line 2145, in files_list_folder
r = self.request(
File "/home/mukesh/Documents/BOVIWALK/projects/pose_estimation/boviwalk-ai/venv/lib/python3.10/site-packages/dropbox/dropbox_client.py", line 326, in request
res = self.request_json_string_with_retry(host,
File "/home/mukesh/Documents/BOVIWALK/projects/pose_estimation/boviwalk-ai/venv/lib/python3.10/site-packages/dropbox/dropbox_client.py", line 476, in request_json_string_with_retry
return self.request_json_string(host,
File "/home/mukesh/Documents/BOVIWALK/projects/pose_estimation/boviwalk-ai/venv/lib/python3.10/site-packages/dropbox/dropbox_client.py", line 596, in request_json_string
self.raise_dropbox_error_for_resp(r)
File "/home/mukesh/Documents/BOVIWALK/projects/pose_estimation/boviwalk-ai/venv/lib/python3.10/site-packages/dropbox/dropbox_client.py", line 643, in raise_dropbox_error_for_resp
raise PathRootError(request_id, err)
dropbox.exceptions.PathRootError: PathRootError('b0bc4fd1e82647deae8616b37255c2cc', PathRootError('invalid_root', TeamRootInfo(home_namespace - Здравко4 years agoLegendary | Level 20
Hi mukesh111,
Take a look on Greg's post on this page top. There is pretty clear where 'team_space_namespace_id' comes from. Try reproduce something similar. 😉 One more thing, at present access token is 'short lived' only. If you need long term access, refresh token may be object of consideration from your side.
Hope this helps.
- mukesh1114 years agoNew member | Level 2
Thanks for the reference it helped. I see that there are solutions to download files are recreate the whole structure and downloading them. Is there a single function that can handle downloading a complete directory
ex: I want to download a whole FolderA with (subfolder1, subfolder2, subfolder3)
I could only find the below for files is there for folders by any chance?:
dbx_admin_team_root.files_download_to_file() - Здравко4 years agoLegendary | Level 20
Hi again mukesh111,
You can download a folder as zip file. You can use the zip stream using files_download_zip and unzip the content on fly or save it as file using files_download_zip_to_file. 😉
Good luck.
About Discuss Dropbox Developer & API
Make connections with other developers
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!