4
votes

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
If you use a "modern" IDE, once you type "dbx." it should "tell" you which methods you can call. Or just try to read documentation, most "serious" apps / sites have one - Aaron_ab
@Aaron_ab I use IDLE (the one that comes with python) so I didn't get any suggestions. Also I searched for quite a while but documentation was really hard to find, all I found was APIv1's documentation. - user9888447
Also I am confused as to why this question is getting downvoted? If someone would like to tell me why, I'd like to improve the question :) - user9888447
A question gets downvoted if it "does not show any research effort". All you had to do is google "DropBox API v2 documentation" and you would have answered your own question. - slightly_toasted
@slightly_toasted That's what I mean, I googled exactly what you suggested and couldn't find the documentation that was given to me by yourself :/. Thank you for letting me know though! :) - user9888447

2 Answers

4
votes

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)

0
votes
dbx.files_delete(path)

is deprecated. Use

dbx.files_delete_v2(path)

instead.