Delete a Dropbox file using Python (API V2)

Viewed 3226

I am trying to delete a file. I tried using: dbx.file_delete() however I get an AttributeError.

AttributeError: 'Dropbox' object has no attribute 'file_delete'

This is what I found here.

file_delete(path)

Delete a file or folder.

Parameters path The path of the file or folder. Returns A dictionary containing the metadata of the just deleted file.

For a detailed description of what this call returns, visit: https://www.dropbox.com/developers/core/docs#fileops-delete

I believe this is because file_delete() is from API V1, however I'm using API V2. I looked around, but couldn't find API V2 documents. So how do I delete a file on dropbox using python using Dropbox API V2?

Thank you!

  • Sidenote: (dbx = dropbox.Dropbox(access_token))
2 Answers

According to the Dropbox APIv2 documentation, the method for deleting a file or folder is:

dbx.files_delete(path)

Where dbx = dropbox.Dropbox(access_token)

dbx.files_delete(path)

is deprecated. Use

dbx.files_delete_v2(path)

instead.

Related