I’m working on a project where I need to get all files from Google Drive using their API v2. The problem is that I don’t want any trashed or deleted files to show up in my results.
I found in the documentation that I should use a parameter to filter these out, so I’m making this call:
GET https://www.googleapis.com/drive/v2/files?trashed=false
But when I run this request, I still see files that are sitting in the trash bin. Has anyone else run into this issue? Am I doing something wrong with the API call, or is this maybe a bug with the Drive API itself?
same issue here last month. switch to q='trashed=false' in your query params instead of just trashed=false. drive api v2 gets picky about that filter format sometimes - fixed it for me.
I encountered a similar challenge while working with the Drive API. The issue with using ‘trashed=false’ is that it can sometimes include files that are technically trashed, especially if they were recently moved there. To effectively filter these out, I recommend checking the ‘labels.trashed’ property for each file in the response. If you find any files with this label set to true, you should exclude them from your final list. Additionally, if you have access to it, consider upgrading to Drive API v3 for improved reliability in handling trashed files.
Had this exact headache a few months back building a file sync tool. The trashed parameter is super inconsistent in API v2, especially with shared files or stuff in nested folders where the parent got trashed. What worked for me was combining the trashed filter with an explicit query for files that actually have parents. Try trashed=false&q=parents+in+root or check each file’s parent references to make sure none of the parent folders are trashed. Also, there’s sometimes a delay between when something gets trashed and when the API actually shows it.