Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to use the properties query with Drive.Files.List in Google Apps Script v5

I’m trying to use the Advanced Google Drive service in Google Apps Script to find files with a given custom property value

Drive.Files.list({ "corpora": "allDrives", "includeTeamDriveItems": true, "q": "'1tfT0BtCg2Z7B7dviOqNQsZTdSjrX5V9B' in parents and trashed = false and properties has {key='photoId' and value='AJHPqhQHfoNqbZSdk8ZUU-RILziCVXViIWPKBG46RIcTVSqzijyVOwyvk1hRE-PxCv3LGXlcT7e7AacOUjKxrUdnG6ssS4YdnQ'}", "supportsTeamDrives": true })

This code as written gives the error API call to drive.files.list failed with error: Invalid query, however if I remove and properties has {...} it will run fine.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I think I need to escape the curly braces somehow however I can’t quite figure out how to do so?

Any help is much appreciated!

>Solution :

visibility parameter is not optional in v2. Use

"
'1tfT0BtCg2Z7B7dviOqNQsZTdSjrX5V9B' in parents and
 trashed = false and
 properties has {
    key='photoId' and 
    value='AJHPqhQHfoNqbZSdk8ZUU-RILziCVXViIWPKBG46RIcTVSqzijyVOwyvk1hRE-PxCv3LGXlcT7e7AacOUjKxrUdnG6ssS4YdnQ' and 
    visibility='PRIVATE'
 }
"
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading