I am using Google Drive API v3 to access about the drive like space quota.
And, no matter what I do, I am stuck with this error:
Fatal error: Uncaught exception 'Google_Service_Exception' with message 'Error calling **GET https://www.googleapis.com/drive/v3/about?fields=name**: (400) Invalid field selection name' in /var/webs/includes/google-api-php-client/src/Google/Http/REST.php:110
Stack trace:
#0 /var/webs/includes/google-api-php-client/src/Google/Http/REST.php(62): Google_Http_REST::decodeHttpResponse(Object(Google_Http_Request), Object(Google_Client))
#1 [internal function]: Google_Http_REST::doExecute(Object(Google_Client), Object(Google_Http_Request))
#2 /var/webs/includes/google-api-php-client/src/Google/Task/Runner.php(174): call_user_func_array(Array, Array)
#3 /var/webs/includes/google-api-php-client/src/Google/Http/REST.php(46): Google_Task_Runner->run()
#4 /var/webs/includes/google-api-php-client/src/Google/Client.php(593): Google_Http_REST::execute(Object(Google_Client), Object(Google_Http_Request))
#5 /var/webs/includes/goog in /var/webs/includes/google-api-php-client/src/Google/Http/REST.php on line 110
$googleClient = $this->getClient();
$googleClient->setAccessToken($accessToken);
$googleDrive = new Google_Service_Drive($googleClient);
//fields can be found here: https://developers.google.com/drive/v3/web/migration#fields
$optParams = array(
'fields' => 'name'
);
print_r($googleDrive->about->get($optParams));
Please check that I am already making a perfect URL for the call: GET https://www.googleapis.com/drive/v3/about?fields=name But, still there is this error. Is there any parameter I am missing?
Please, can anyone tell me if there is problem with the API itself?
In v3 the fields definition has changed, it should be
fields=storageQuota,user/displayName
instead of
fields=name
Anyway, I have no exprience with PHP.
Ref:
https://developers.google.com/drive/v2/reference/about
https://developers.google.com/drive/v3/reference/about
You can check yourself all the fields available:
For now these were the fields I found: appInstalled, exportFormats, folderColorPalette, importFormats, kind, maxImportSizes, maxUploadSize, storageQuota & user
.
If you need to check which fields are allowed, please go to https://developers.google.com/drive/v3/reference/about/get & do "Try It!".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With