Google Drive API v3: неверный выбор полей

Я использую Google Drive API v3 для доступа к диску как квота.

И что бы я ни делал, я застрял с этой ошибкой:

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));

Пожалуйста, проверьте, что я уже делаю идеальный URL для звонка:
ПОЛУЧИТЬ https://www.googleapis.com/drive/v3/about?fields=name
Но все же есть эта ошибка. Есть ли какой-то параметр, который мне не хватает?

Пожалуйста, кто-нибудь может сказать мне, если есть проблема с самим API?

3

Решение

В v3 определение полей изменилось, оно должно быть

fields=storageQuota,user/displayName

вместо

fields=name

Во всяком случае, у меня нет опыта работы с PHP.

Ref:
https://developers.google.com/drive/v2/reference/about
https://developers.google.com/drive/v3/reference/about


Вы можете проверить все доступные поля:
На данный момент это были поля, которые я нашел: appInstalled, exportFormats, folderColorPalette, importFormats, kind, maxImportSizes, maxUploadSize, storageQuota & user,

Если вам нужно проверить, какие поля разрешены, перейдите по ссылке https://developers.google.com/drive/v3/reference/about/get & сделать «Попробуй!»

8

Другие решения

для получения файлов со всеми возможными полями, которые я использовал files/*

пример запроса https://www.googleapis.com/drive/v3/files?fields=files/*

0

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector