php-samples icon indicating copy to clipboard operation
php-samples copied to clipboard

Uncaught Google_Service_Exception error code 400 FAILED_PRECONDITION

Open luckydevilru opened this issue 5 years ago • 1 comments

In one sheet its work fine. I try to get cells from another sheet document and it became impossible. I always get this errors, event try to do it from owner accont. Owner accaunt work fine with another sheet docs too.

Errors:

Warning: count(): Parameter must be an array or an object that implements Countable in /directory/import/Google/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 67

Warning: count(): Parameter must be an array or an object that implements Countable in /directory/import/Google/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php on line 67

Fatal error: Uncaught Google_Service_Exception: { "error": { "code": 400, "message": "This operation is not supported for this document", "errors": [ { "message": "This operation is not supported for this document", "domain": "global", "reason": "failedPrecondition" } ], "status": "FAILED_PRECONDITION" } } in /directory/import/Google/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /directory/import/Google/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 /directory/import/Google/vendor/google/apiclient/src/Google/Task/Runner.php(181): Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /directory/import/Google/ven in /directory/import/Google/vendor/google/apiclient/src/Google/Http/REST.php on line 118

Sample: ` <?

ini_set('error_reporting', E_ALL); ini_set('display_errors', 1); ini_set('display_startup_errors', 1);

require_once DIR . '/Google/vendor/autoload.php'; $client = new \Google_Client(); $client->setApplicationName('Google sheet and PHP'); $client->setScopes([\Google_Service_Sheets::SPREADSHEETS_READONLY]); $client->setAccessType('offline'); // $client->setAuthConfig(DIR.'/EraVitex-ec458f567057.json'); $client->setAuthConfig(DIR.'/Eravitex-736c25228468.json'); #prokh.sergey $service = new Google_Service_Sheets($client); // var_dump($service); // $spreadsheetId = "1AUGdmO645L4n-mHH9vxgTAUmPG2vkhqmtay5-9w66Ak"; // $spreadsheetId = "1mKLemNR2VMDj_wE5crSiR11-mq8VrirVcjCAJ4Caq_k"; //-new $spreadsheetId = "1QrfFUFTsMNHTM3SPvD24_Y2WXM64WcdI";

// $range = "Ковщики!A1:B10"; $range = "TIU!A1:B10"; $response = $service->spreadsheets_values->get($spreadsheetId, $range); $values = $response->getValues(); if (empty($values)){ echo 'no data'; } else{ $mask ="%10s %-10s %s\n"; foreach ($values as $row){ echo $row[0].'-'.$row[1]."\n"; } }

?>`

Steps to Reproduce the Problem

  1. Tel me please how to solve this problems

Specifications

  • PHP Version 7.2.29-1+ubuntu16.04.1+deb.sury.org+1:
  • Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-176-generic x86_64):

luckydevilru avatar May 13 '20 17:05 luckydevilru

I fogot to tell what if do with this guide https://developers.google.com/sheets/api/quickstart/php?hl=ru - I got the same mistakes.

Its may be becouse the document have more then one author?

luckydevilru avatar May 14 '20 07:05 luckydevilru