Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to search for **not** sharedWithMe with Google Drive API v3?

According to the API documentation you can search on 'sharedWithMe' in the same way as 'trashed':

trashed      boolean    =, !=   Whether the file is in the trash or not.
sharedWithMe boolean    =, !=   Files that have been shared with the authorized user.

Queries like "trashed", "not trashed" and "trashed=false" all work as expected. Also "sharedWithMe" works.

However whats does not work is "not sharedWithMe" or "sharedWithMe=false". What is the right syntax or is this a bug?

Example: q=not+sharedWithMe

Error:

"domain": "global",
"reason": "invalid",
"message": "Invalid Value",
"locationType": "parameter",
"location": "q"
like image 796
rmuller Avatar asked Nov 13 '16 19:11

rmuller


People also ask

Can you search for shared drive?

Search by the file's creator In the shared drive search box, enter creator: followed by the email of the person in your organization who created the file. For example, creator:[email protected]. and add more search operators. Press Enter.


1 Answers

I also believe this problem is a bug in the google drive API implementation.

I am working around this problem (in python) by using the "sharedWithMeTime" attribute that I get back from each list request. After I get back all the items (sharedWithMe or not), I then test for whether sharedWithMeTime attribute exists in each item. If not, then the item must be "not sharedWithMe", which is what I wanted to use as the query, but was getting the error described by the OP.

Link to the python doc on list request is here: https://developers.google.com/resources/api-libraries/documentation/drive/v3/python/latest/drive_v3.files.html#list

like image 98
MitchN Avatar answered Sep 30 '22 23:09

MitchN