I need to trash a file by using the Google Drive API V3. While V2 has a trash method, V3 doesn't have one. Instead, you need to modify the file's metadata.
I've searched everywhere but couldn't find an answer for this. I've found an example for Android here in stackoverflow, but I don't know how to translate it into python: Google Drive Rest API v3 - how to move a file to the trash?.
Here's the function that's supposed to trash the files:
def trashFile(service, file_id):
# First retrieve the file from the API.
file = service.files().get(fileId=file_id,fields="trashed" ).execute()
# File's new metadata.
file['trashed'] = True
# Send the request to the API.
updated_file = service.files().update(body=file).execute()
return updated_file
return None
Everything runs smoothly, the file is retrieved, the file ID is correct, the update command is executed, but the file is not trashed.
What should I do? Thanks in advance for your help.