cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know what we learned at IBC? Check out our learnings on media, remote working and more 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: 

Re: API to upload files to folders outside of user account folder

API to upload files to folders outside of user account folder

deeptir94
Explorer | Level 4

Hello,

I need to upload files using API to a folder that is outside of my current user account (the user ID I’m logged in with). 

However, when using the API, the folder structure is being created within my user folder instead of uploading to the existing target folder. How can I upload files to these other folders?

For example:

  • The folder labeled with "svc" is my user folder, where the files are currently being uploaded. I assume this is my root folder.
  • "Business Service" is the target folder where I want to upload the files.

deeptir94_0-1723963436094.png

 

Thanks

 

4 Replies 4

Здравко
Legendary | Level 20

Hi @deeptir94,

Your issue is related to the fact that API default access start from users home folder. While for individual users their home is their account root, for business user home folder (the your folder starting with "svc" as seems) is not account root (or at least not mandatory to be - in most cases these days, it is NOT). In business accounts, you need to set the account root explicitly to override the default home folder when you need (like in your case). This happens using HTTP header "Dropbox-API-Path-Root" set to appropriate namespace id (the root namespace id in your case, but you can set any other namespace id if you want that namespace to be your access root). Take a look here (and linked resources there) for additional details. Use appropriate method if you use some of the supported SDKs.

Hope this helps.

iNeil
Dropbox Engineer
Hello @deeptir94,

As mentioned by Здравко, by default, API calls to the Dropbox API operate within the "member folder" of the connected account. You can configure the API calls to operate in the team space that is outside of the "member folder" by setting the "Dropbox-API-Path-Root" header in your Dropbox API request.
 
Below I have provided an example "Dropbox-API-Path-Root" header value to access the team space:
 
Dropbox-Api-Path-Root: {".tag": "root", "root": "YOUR_ROOT_NAMESPACE_ID"}
 
You should be able to identify the root_namespace_id by executing the 2/users/get_current_account endpoint. You can also test the 2/users/get_current_account endpoint using our Dropbox API explorer.
 
For further information, please review the following links:

deeptir94
Explorer | Level 4

Hello, thanks for your reply.

I am still not sure how to fetch the namespace id for my folder. The API calls return information regarding the default root folder.

Здравко
Legendary | Level 20

In most cases, setting the account root namespace id is enough since in such a way you can access everything accessible to particular user. So maybe it's the best way for you too. If you want to select from other available namespaces, you can enumerate them using /2/team/namespaces/list/continue.

Hope this sheds a light.

Need more support?