2

I am trying to get a list of folders so that I can do a search for files within all subfolders. I am using this post (alternative 3) as a reference https://stackoverflow.com/a/41741521/1485815

My query is like this (I have tried mimetype and mimeType in the query)

    $optParams = array(
    'pageSize' => 1000
        ,'fields' => 'nextPageToken, files(contentHints/thumbnail,fileExtension,iconLink,id,name,size,thumbnailLink,webContentLink,webViewLink,mimeType,parents, kind, trashed, owners, modifiedTime)'
        ,'q' => "mimeType=application/vnd.google-apps.folder"
       );                

    $service = new \Google_Service_Drive($this->GoogleClient);
    $results = $service->files->listFiles($optParams);

I am authenticated fine, but this query gives an error with the following details

 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value",
    "locationType": "parameter",
    "location": "q"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }

}

StripyTiger
  • 877
  • 1
  • 14
  • 31

1 Answers1

3
  • You want to retrieve the folder list from the Google Drive using googleapis with PHP.
  • You have already been able to use Drive API.
  • You want to know the reason of your issue of Invalid Value.

Modified script:

From:
,'q' => "mimeType=application/vnd.google-apps.folder"
To:
,'q' => "mimeType='application/vnd.google-apps.folder'"

or

,'q' => 'mimeType="application/vnd.google-apps.folder"'
  • Please enclose the value of mimeType by ' and ".

Reference:

halfer
  • 19,824
  • 17
  • 99
  • 186
Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • @StripyTiger Thank you for replying. I'm glad your issue was resolved. – Tanaike Apr 19 '20 at 00:37
  • Hi - I wonder if you wouldn't mind checking this question - I cannot seem to query multiple folders with my query. https://stackoverflow.com/questions/61313289/google-api-query-files-in-multiple-folders-with-php Thank you – StripyTiger Apr 20 '20 at 00:10