I am trying to delete a file which is shared with me using Google Drive API but since I'm not the owner of the file I'm getting a permission error. I looked the on the web and find this solution . I implemented the solution as below:
About about = service.about().get().execute();
String rootId = about.getRootFolderId();
service.parents().delete(fileId, rootId).execute();
However, I cannot delete the file with this code. It doesn't give any error but I can still see the file in my google drive.
PS: I checked the fileId
parameter and it's referencing to the correct file.
Sorry I don't Know java so couldn't provide any code sample.
So In Google Drive API V3 you can no longer get the root folder Id by getRootFolderId
method using About Resource.
Instead you need to use file.get
method, use root
(instead of your file Id) as the fileId
and request additional field id
(passing ?fields=id
) to get the rootFolderId.
In the Drive API V3 they have stopped returning full resource by default. So be careful if you use any code related to V2.
Check out the Fields Section in google drives api official migration document.
Hope this helps.
Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.