Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.

Forum Discussion

craibuc's avatar
craibuc
Explorer | Level 3
2 years ago

Upload a file to a shared folder using the REST API

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

  • iNeil's avatar
    iNeil
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    2 years ago

    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's avatar
    craibuc
    Explorer | Level 3
    2 years ago

    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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,037 PostsLatest Activity: 2 years ago
413 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!