I have an function in Google Apps Script that should list files from yesterday. I want to filter them out upon request as there are many files and I only need the 'latest' ones.
I added the Google Drive API v2 (v3 is not available) in Services for the project.
This code fails:
function getFiles(){
let query = "trashed = false and mimeType = 'application/vnd.google-apps.document' and
createdTime > '2023-03-22T00:00:00.00'";
let files = Drive.Files.list({
useDomainAdminAccess: true,
corpora: "drive",
driveId: "<drive id here>",
includeItemsFromAllDrives: true,
supportsAllDrives: true,
q: query
});
}
With error message:
GoogleJsonResponseException: API call to drive.files.list failed with error: Invalid query
I checked the documentation at https://developers.google.com/drive/api/guides/ref-search-terms, and createdTime is available for v2 (at least it looks like it is available).
Is there something wrong with my query? Incorrect date format? Syntax error? Or is createdTime not available in Drive v2 API?
Btw this work if I remove createdTime from the query.