Search code examples
file-uploadrootdropbox-api

Dropbox API: Upload a File to Root directory for app with Full Dropbox


I created a Dropbox App with:

  • Status: Development
  • Permission type: Full Dropbox

Using the Dropbox API Explorer /upload, I had made a request to upload a file:

curl -X POST https://content.dropboxapi.com/2/files/upload \
  --header 'Authorization: Bearer [** ACCESS_TOKEN **]' \
  --header 'Content-Type: application/octet-stream' \
  --header 'Dropbox-API-Arg: {"path":"","mode":{".tag":"overwrite"},"autorename":true,"mute":false}' \
  --data-binary @'banana.png'

The error response:

Error: 400
Error in call to API function "files/upload": HTTP header "Dropbox-API-Arg": path: The root folder is unsupported.

I would like to understand, is uploading any file to the root directory is not allowed?

I appreciate any feedback, thank you.


Solution

  • When uploading a file to Dropbox using the Dropbox API, you can upload to the root folder, but the path that you supply for the upload needs to include the desired file name.

    So, instead of "", you would supply a value like "/banana.png".

    (Your use of the filename in @'banana.png' is only for telling curl which local file to use. That filename there doesn't get sent to Dropbox.)