Drive API search parameters - Help figure out the Invalid query

444 views
Skip to first unread message

jmm0979

unread,
Aug 26, 2021, 6:52:02 PM8/26/21
to google-apps-sc...@googlegroups.com
Hi,

I am using the search parameters below but I keep getting :"GoogleJsonResponseException: API call to drive.files.list failed with error: Invalid query"
I was hoping someone could help decipher this and point out what I did wrong.

var query_folder = 'title contains = "' + folderName + '" and trashed = false and mimeType ="application/vnd.google-apps.folder" and "' + ownerEmail + '" in owners';

What I am trying to do is search Google Drive using "title contains...", do not include anything in trash, only folders and owned by a specific person.


TiA!

Thanks
JMR

dimud...@gmail.com

unread,
Aug 26, 2021, 8:41:54 PM8/26/21
to Google Apps Script Community
You're using the contains clause in correctly, it shouldn't be followed by an equals sign. Check out the documentation linked below for correct usage:

https://developers.google.com/drive/api/v3/search-files#query_string_examples

jmm0979

unread,
Aug 26, 2021, 9:08:09 PM8/26/21
to google-apps-sc...@googlegroups.com
I did see it and also figured out why I kept getting that error. I did not have a variable set for "ownerEmail".

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/bb7236c4-1b43-42f1-aa36-ae22d534e10cn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages