cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
We are making some updates so the Community might be down for a few hours on Monday the 11th of November. Apologies for the inconvenience and thank you for your patience. You can find out more 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: Upload a file to a shared folder using the REST API

Upload a file to a shared folder using the REST API

craibuc
Explorer | Level 3

I'm attempting to upload a file to a shared (team) folder in Dropbox. 

 

\ (hidden root)

  \[My Personal Folder]

  \My Company Team Folder

    \Activities

        \2024-04-11

           File A

           File B

 

I want to add files to \My Company Team Folder\Activities\2024-04-11.

 

This is the code (PowerShell):

 

$AccessToken = 'XXXXX'

$TeamMemberId = '123456' # an administrator

$InFile = ~/Desktop/SomeFile.pdf

$Destination = '/Activities/2024-04-11/SomeFile.pdf'

 

$Headers = @{
Authorization = 'Bearer {0}' -f $AccessToken
'Dropbox-API-Select-User' = $TeamMemberId
'Dropbox-API-Path-Root' = @{
'.tag'='root'
root=$RootFolderId 
} | ConvertTo-Json -Compress
'Dropbox-API-Arg' = @{
path=$Destination
mode="add"
autorename=$true
mute=$false
} | ConvertTo-Json -Compress
}
 
$Response = Invoke-WebRequest -Method Post -Uri 'https://content.dropboxapi.com/2/files/upload' -Headers $Headers -ContentType 'application/octet-stream' -InFile $InFile
 
When I run the script, I get an error that reads "path/no_write_permission/".
2 Replies 2

iNeil
Dropbox Engineer

Hello @craibuc,

Based on the error message 'path/no_write_permission/', this indicates that you don’t have write permissions to the folder to upload the file. For example, you don’t have write permission to the folder /Activities/2024-04-11. Please double-check if you have editor permission on the folder.

If you are still having difficulty, could you provide the values for the $TeamMemberId and $RootFolderId? Alternatively, you can open an API ticket using the following link: https://www.dropbox.com/developers/contact

craibuc
Explorer | Level 3

I found the solution: I needed to include the team-folder's name in the path.  So, instead of '/Activities/2024-04-11/SomeFile.pdf', it needed to be '/My Company Team Folder/Activities/2024-04-11/SomeFile.pdf'

 

The documentation on this is *terrible*, not to mention the contortions that developers need to perform to list shared folders and add content to them.  Your API needs a complete revision to make it easier to use.

Need more support?