Google Analytics Data API v1 - GPBDecodeException: Error occurred during parsing: Fail to push limit.
Can't Migrate to the Google Analytics Data API v1.
- OS: Linux
- PHP version: 7.3.28
- Package name and version: "google/analytics-data": "0.8.2"
My steps
- I crate GA4 property.
- Activate "Google Analytics Data API" on "Google Cloud Platform"
- Create Service account on "Google Cloud Platform"
- Generate JSON key
- Add Service account email to Google Analitics 4 Property access manager as Viewer
- Download Data API v1 (PHP) by composer
- Write PHP code:
require '/lib_way/vendor/autoload.php';
use Google\Analytics\Data\V1beta\BetaAnalyticsDataClient;
use Google\Analytics\Data\V1beta\DateRange;
use Google\Analytics\Data\V1beta\Dimension;
use Google\Analytics\Data\V1beta\Metric;
$keyfile=$_SERVER['DOCUMENT_ROOT'].'/GoogleAPI.json';
$client=new BetaAnalyticsDataClient(['credentials'=>$keyfile]);
at this step everything is working. but when I'm tring to make an API call:
$propery_id="3*nums*6";
$response = $client->runReport([
'property' => 'properties/' . $propery_id,
'dateRanges' => [new DateRange(['start_date' => '2022-03-31','end_date' => 'today'])],
'dimensions' => [new Dimension(['name' => 'city'])],
'metrics' => [new Metric(['name' => 'activeUsers'])]
]);
I recive this error: Fatal error: Uncaught Google\Protobuf\Internal\GPBDecodeException: Error occurred during parsing: Fail to push limit. in .../vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php on line 340
Google\Analytics\Data\V1beta\DateRange->__construct( ) .../ga4_analytics_get_data.php:49 GPBMetadata\Google\Analytics\Data\V1Beta\Data::initOnce( ) .../DateRange.php:71 Google\Protobuf\Internal\DescriptorPool->internalAddGeneratedFile( ) .../Data.php:285 Google\Protobuf\Internal\FileDescriptorSet->mergeFromString( ) .../DescriptorPool.php:61 Google\Protobuf\Internal\FileDescriptorSet->parseFromStream( ) .../Message.php:775 Google\Protobuf\Internal\FileDescriptorSet->parseFieldFromStream( ) .../Message.php:811 Google\Protobuf\Internal\Message::parseFieldFromStreamNoTag( ) .../Message.php:515 Google\Protobuf\Internal\GPBWire::readMessage( ) .../Message.php:435 Google\Protobuf\Internal\CodedInputStream->incrementRecursionDepthAndPushLimit( ) .../GPBWire.php:286 Google\Protobuf\Internal\CodedInputStream->pushLimit( ) .../CodedInputStream.php:363
Tried many other "runReport" parameters - same result
Any information on how to solve it? Thanks.
@Aljnk (untested) can you try changing to 'date_ranges' from 'dateRanges' in runReport args?
Closing due to no repro