Google Analytics API 500 internal error during AdW

2019-07-21 22:51发布

问题:

I'm getting Error :

"code":500,"message":"There was an internal error."

exception every time I'm trying to link Google analytics to Adwords via Analytics Management API.

Code is pretty straightforward (PHP), just like documentation example:

$adwordsAccounts = [];

foreach ($adwordsAccountIds as $customerId) {  
    $adwordsAccount = new \Google_Service_Analytics_AdWordsAccount();
    $adwordsAccount->setCustomerId($customerId);
    $adwordsAccount->setAutoTaggingEnabled(true);
    $adwordsAccounts[] = $adwordsAccount;
}

$adWordsLink = new \Google_Service_Analytics_EntityAdWordsLink();
$adWordsLink->setName('AdWords Link');
$adWordsLink->setAdWordsAccounts($adwordsAccounts);

$response = $client->management_webPropertyAdWordsLinks->insert($accountId, $webPropertyId, $adWordsLink);

google-api-php-client library version is latest (2.2.0)

回答1:

From Account management

Write operations in the Management API (e.g. create, update, delete, patch) for Web Property, View (Profile), and Goal resources are currently available as a developer preview in limited beta. If you're interested in using these features, request access to the beta.

Unless i am mistaken you have not applied for access to the beta program. Note it can take up to a month to get access you will hear from Google if you have been granted access.

Assuming that you have applied for beta.

There appears to be a bug in this currently the bug log can be found here. Google has been notified we will have to wait for them to fix it.