We Want to Hear From You! What Do You Want to See on the Community? Tell us here!

Forum Discussion

mgjones1984's avatar
mgjones1984
New member | Level 2
7 years ago

Write File to Team location - Python API

Hi,

I have a simple python script to write a file to Dropbox. The issue I'm having is this only seems to give me access to my user area and I need to write the file to the team area. I have read  documentation but am struggling to find any simple examples using the python API.

Thanks

Matt

import dropbox

access_token = '*************************************'

file_from = 'test.txt'
file_to = '/test_dropbox/test.txt'

dbx = dropbox.Dropbox(access_token)

with open(file_from, 'rb') as f:
    dbx.files_upload(f.read(), file_to)

 

1 Reply

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    7 years ago

    It sounds like your team is using the "team space" configuration. You can access the team space via the API. To do so, you'll need to use the namespace IDs to specify which area you want to access. I recommend reading the Namespace Guide, which covers this in detail:

    https://www.dropbox.com/developers/reference/namespace-guide 

    In the Python SDK in particular, to specify a particular root, you should use `with_path_root`. For example:

    dbx.with_path_root(dropbox.common.PathRoot.root("XXXXXXXXX")).files_list_folder("")

    or:

    dbx.with_path_root(dropbox.common.PathRoot.namespace_id("XXXXXXXXX")).files_list_folder("")

     

About Discuss Dropbox Developer & API

Node avatar for Discuss Dropbox Developer & API
Make connections with other developers814 PostsLatest Activity: 7 hours ago
275 Following

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 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!