6

In the Google Drive SDK documentation, I can't figure out how to access the root list of files/folders shared with me by others, any idea?

I tried to search for files not owned by me, meaning query files/list with the following parameter:

"q=not 'me' in owners"

But that returns all the files owned by others, not only the "root list" of those files.

Thanks for your help.

Martin
  • 2,290
  • 1
  • 23
  • 28

2 Answers2

13

Apparently, there is a new search parameter, called sharedWithMe. Setting the Q to "sharedWithMe" is enough to receive the parent folders and files that were shared with the user. It can be combined with other parameters too - for example "sharedWithMe and trashed=false".

You have probably already found about it, but it might be useful to have an answer of this question.

stan0
  • 11,549
  • 6
  • 42
  • 59
  • Yes indeed, but unfortunately this search parameter doesn't allow you to get *ONLY* the *ROOT* elements of this hierarchy. – Martin Nov 27 '12 at 10:47
  • 2
    What do you mean? When a user shares with me Folder1 that has subfolders and files inside, I can get only Folder1 using "sharedWithMe". Any files and folders that have been explicitly shared through the menus will be listed in the response. Any files and folders that are inside a shared folder, won't be listed in the response. Or do you need the shared items that are in the sharing user's root? – stan0 Nov 28 '12 at 09:07
  • I'm not sure if they changed something or if I haven't sleep enough these days but it's indeed working now. :) Thanks Stan! – Martin Nov 28 '12 at 12:42
  • If somebody shares you just a file then that file is "in Google Docs root". At least old Google Docs API was showing that these objects have root as parent. – Robert Grezan Dec 25 '12 at 05:50
  • OK Sounds to me like they give you the first level of the files shared with you and folders. So it will return all lowest level folders, then also the files that are directly shared. Otherwise it expects you to use `children()` to get the rest of the files. – Nicholas DiPiazza Nov 28 '16 at 14:01
  • Hi @stan0 ,@RobertGrezan! I have a problem with combined parameters. When I do with only 'sharedWithMe' option I get response { "id": "somefolderid", "name": "Name"}. And when I do " 'somefolderid' in parents" it returns all files and folders from somefolderid folder. But when I do " 'somefolderid' in parents and sharedWithMe" it returns empty collection. Does anybody could explain where is mistake? – Ant Jan 10 '17 at 00:33
  • @Anton what are you trying to achieve with that query? It looks strange – stan0 Jan 10 '17 at 11:23
  • @stan0 I'm trying to get all shared-with-me files/folders which has somefolderId as parent. – Ant Jan 10 '17 at 11:34
-4

Something more like:

"q=not 'me' in owners and 'root' in parents"

Ali Afshar
  • 40,967
  • 12
  • 95
  • 109