ZorgoZ
ZorgoZ

Reputation: 3567

Google Drive API - query owned items

I am working on a tool, and I want to query my own folders only. I can't formulate a query string that is accepted. I had read Search for files page, and I am experimenting now with the API explorer.

  1. String mimeType = 'application/vnd.google-apps.folder' yields folders. Good start.
  2. ownedByMe, ownedByMe = true and ownedByMe = false all yield error 400 (Invalid Value), while when I use this field in the result set, it is shown.
  3. sharedWithMe, sharedWithMe = true and sharedWithMe != false yields result, but interestingly I can't add this field to the result set and neither is it included in the field selector.
  4. sharedWithMe = false, not sharedWithMe, not sharedWithMe = true and sharedWithMe != true all yield error 400

And I have tried some other less common syntaxes but now I am out of ideas :(

Upvotes: 1

Views: 677

Answers (1)

Richard Campbell
Richard Campbell

Reputation: 3621

Use "[my email] in owners" or "'me' in owners":

  var files = DriveApp.searchFolders("\(mimeType = 'application/vnd.google-apps.folder'\) and \('[email protected]' in owners\)");

  var files = DriveApp.searchFolders("\(mimeType = 'application/vnd.google-apps.folder'\) and \('me' in owners\)");

Upvotes: 1

Related Questions