Forum Discussion

kotique's avatar
kotique
Explorer | Level 3
4 years ago

Move empty folder via Python API

I am using Python SDK for Dropbox and trying to move one folder (empty if it is important) to another. Example:
dbx = dropbox.Dropbox(config.DROPBOX_ACCESS_TOKEN)

src="/some/long/path/to/the/folder"
dst = "/on_review"

dbx.dbx.files_move(src, dst)

And always got this error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/username/.venv/lib/python3.9/site-packages/dropbox/base.py", line 2222, in files_move
    r = self.request(
  File "/home/username/.venv/lib/python3.9/site-packages/dropbox/dropbox_client.py", line 346, in request
    raise ApiError(res.request_id,
dropbox.exceptions.ApiError: ApiError('922df7920b19424a97600d5250a1ee90', RelocationError('to', WriteError('conflict', WriteConflictError('folder', None))))

 

Ideally I do not want to think "whether folder contains anything or not", I just want to pick folder `/a/b/c/d` and move it so new path will be `/on_review/d`.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    [Cross-linking for reference: https://stackoverflow.com/questions/68094001/dropbox-python-api-move-empty-folder-to-another-folder ]

     

    A 'to/conflict/folder' error indicates that the move failed because a folder already exists at the specified destination path.

     

    When moving something via the API, the destination path you specify should be the full desired path of the moved item, not just the path of the parent folder where you want to put the item. So, in this case, instead of setting dst = "/on_review", you should set dst = "/on_review/d" (or whatever you want it called).

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,951 PostsLatest Activity: 14 minutes ago
352 Following

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!