rtom
rtom

Reputation: 209

Search for folder with parents set in google drive api

I want to search for folder in google drive, but I need to deal with case that folder doesn't have parent.

$file = $this->service->files->listFiles(
                                array('q' =>  
                                       "mimeType = 'application/vnd.google-apps.folder' 
                                        and trashed = false 
                                        and name = '".$name."' 
                                        and '".$parent."' in parents" ));

I don't know how to set last parameter, according to documentation it should be like that, but when parent is NULL it doesn't return anything.

Upvotes: 2

Views: 3936

Answers (1)

Linda Lawton - DaImTo
Linda Lawton - DaImTo

Reputation: 116938

All files have parents root is the parent of everything. I don't think I understand what you are trying to do. Search for a folder in drive all you should need is mimeType = 'application/vnd.google-apps.folder' and name = 'test'

Tip:

Use string format to avoid issues with your quotes.

string.Format("mimeType = 'application/vnd.google-apps.folder' and trashed = false and name = '{0}' and '{1}' in parents",name,parent  )

Upvotes: 2

Related Questions