cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We've been busy working on some major updates to the Community, so check out what's changing, what’s staying the same and what you can expect from the Dropbox Community 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: 

List content of Team forlders Within Python SDK

List content of Team forlders Within Python SDK

trayer72
New member | Level 2

Hi,

I'm trying to list all the files contained in a dropbox business team folder.

I'm using the official Python SDK.

I tried to use the dropbox.DropboxTeam class.

Here is my code : 

 

dbx = dropbox.DropboxTeam("<TOKEN>");

 

I can list all the namespaces availables with : 

 

for entry in dbx.team_namespaces_list().namespaces:
    print(entry.namespace_id +" / "+entry.name)

When i use the team_team_folder_list() :

 

for entry in dbx.team_team_folder_list().team_folders:
    print(entry)

 

I retrieve the top-level folder which is the shared workspace.

Then i want to list all the files and folder in this directory : 

p = dropbox.common.PathRoot.namespace_id("<TEAM_FOLDER_ID>")
for entry in dbx.with_path_root(p).team_team_folder_list().team_folders:
    print(entry)

I always get the error : 

Traceback (most recent call last):
  File "dropbox_hausfeld.py", line 40, in <module>
    for entry in dbx.with_path_root(p).team_team_folder_list().team_folders:
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dropbox/base_team.py", line 1808, in team_team_folder_list
    None,
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dropbox/dropbox.py", line 274, in request
    timeout=timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dropbox/dropbox.py", line 365, in request_json_string_with_retry
    timeout=timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dropbox/dropbox.py", line 456, in request_json_string
    raise BadInputError(request_id, r.text)
dropbox.exceptions.BadInputError: BadInputError('00f98974766854e558110eec5a014ed7', 'Error in call to API function "team/team_folder/list": Unexpected path root value in HTTP header "Dropbox-API-Path-Root": "{\\".tag\\": \\"namespace_id\\", \\"namespace_id\\": \\"<TEAM_FOLDER_ID>\\"}"')

Is this the good way to do it ? How can i solve the issue ?

How can i access all the files in a team dropbox ?

Thanks in advance for your help,

Thomas.

 

 

 

 

 

1 Reply 1

Greg-DB
Dropbox Staff

Setting a path root isn't required or expected when calling team-level endpoints such as team_team_folder_list. It is only supported for user-level filesystem endpoints.

Further, team_team_folder_list is only for listing the team folders themselves. To list the contents of any particular folder, you should use files_list_folder and files_list_folder_continue instead. Since you have a Dropbox Business API access token, for a team, setting that up would look like this:

 

dbx_as_user = dropbox.DropboxTeam("<TOKEN>").with_path_root(p).as_user(member_id)
dbx_as_user.files_list_folder("")

This uses as_user to set a particular user to operate as, returning a Dropbox object.

You can first get the team member ID, for the member_id value in the sample above, from various places via a DropboxTeam object, such as team_members_list/team_members_list_continue, or team_members_get_info.

You can find more information on the path root and member file access features, respectively, in the Namespace Guide and Member file access documentation.

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?