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 ...
- 6 years ago
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".
phermans
6 years agoExplorer | Level 3
In your code sample, you use the variable
team_space_namespace_id
but I don't know what that is.....where do I get the id of the Team Folder? Is there a complete example of simply listing all the folders and files in a team folder using python?
Thanks
Greg-DB
Dropbox Community Moderator
5 years agophermans The 'team_space_namespace_id' for a team using the team space configuration would be the 'root_namespace_id' value, e.g., as returned by /2/users/get_current_account. I recommend reviewing the Team Files Guide for more context if you haven't already.
In the Python SDK in particular, you can call that via users_get_current_account, so you can get that information from the returned FullAccount.root_info.
Hopefully that should fill in the missing piece for you so you can connect that with the rest of the code and information in the earlier comments in this thread, but let us know if something still isn't working for you.
- phermans5 years agoExplorer | Level 3
Greg-DB Thanks for the quick reply. I know you are trying to be helpful but I have tried reading most of the guides, and find them to be mostly not helpful.
So I jsut tried what you suggested, and what I could glean from the Python SDK...and it still won't work.
dbxt = dropbox.DropboxTeam(_dropbox_token).as_admin(_member_id)
full_accnt = dbxt.users_get_current_account()yields an error that tells me little.....Error in call to API function "users/get_current_account": Invalid select user id format')
I don't know what a "select user id format" is, or where it is documented but it must make sense to someone who wrote this stuff.
So I looked at python sdk docs and find that it tells me this:
users_get_current_account() Get information about the current user’s account.
Wonderful.....imagine that, a function called get users_get_current_account gets the current user's account! It apparently takes no arguments and it apparently doesn't work for some esoteric reason.
Sorry for the rant, but this has already cost hours of time to attempt to do the most basic thing - get a list of files and folders in the team folder.
I will continue to guess and check until my token expires (yet again) and I waste a few more hours but after that I will probably say the hell with Dropbox API, it doesn't appear to be worth the time to learn it.
- Greg-DB5 years ago
Dropbox Community Moderator
phermans Thanks for the feedback!
I see you're currently getting the error:
Invalid select user id format
That's referring to the value you're passing to identify the particular user account from the team to operate on, which in your case is via the as_admin method to which you're supplying your variable '_member_id'. So, it appears your '_member_id' value is not valid. That value should be a "team member ID" (which starts with "dbmid:"). You can get the team member IDs from a number of places on the API, such as team_members_get_info and team_members_list/team_members_list_continue. It's returned in the TeamMemberProfile.team_member_id field.
Also, note that API calls for teams using the team space configuration default to the "team member folder", not the "team space". You can access the team space though by setting the relevant root. You can do so via the with_path_root method. (You mentioned reviewing some guides, but just in case you missed this one, the Team Files Guide would be the most relevant to this part.)
So, putting that all together, it sounds like this is what you're looking to do:
import dropbox _dropbox_token = "<ACCESS_TOKEN>" admin_email = "<EMAIL_ADDRESS>" dbx_team = dropbox.DropboxTeam(_dropbox_token) _member_id = dbx_team.team_members_get_info([dropbox.team.UserSelectorArg.email(admin_email)])[0].get_member_info().profile.team_member_id dbx_admin = dbx_team.as_admin(_member_id) root_namespace_id = dbx_admin.users_get_current_account().root_info.root_namespace_id dbx_admin_team_root = dbx_admin.with_path_root(dropbox.common.PathRoot.root(root_namespace_id)) listing = dbx_admin_team_root.files_list_folder('') 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)Hope this helps!
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!