Got UNEXPECTED_INTERNAL_API_ERROR for account activity API

12 views
Skip to first unread message

Pallavi Sharma

unread,
Jan 9, 2017, 10:00:45 AM1/9/17
to AdWords API Forum
In my php app, I'm trying to find adwords account activity via CustomerSyncService API. This works fine with few customer clients, but fail with one client. Also it was working fine for this specific client till 3 days ago. 
Error I got is this :
[SoapFault] [InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.services.common.error.InternalApiError.<init>(InternalApiErro]

Any reason ? 

related code (don't look for typos, it is working fine in other cases):
    private function downloadCSVReportActivity($access_token, $expires_in,$timestamp, $clientCustomerId, $fromDate, $toDate) {
        $user
= new \AdWordsUser();
        $user
->LogAll();
        $user
->SetClientCustomerId($clientCustomerId);
        $oAuth2Info
= $user->GetOAuth2Info();
       
//SET access token value in oauth..
       
//thsi is required while using new service
        $oAuth2Info
['access_token'] = $access_token;
        $oAuth2Info
['expires_in'] = $expires_in;
        $oAuth2Info
['timestamp'] = $timestamp;
       
// Download report.
        $user
->SetOAuth2Info($oAuth2Info);
        $campaignService
= $user->GetService('CampaignService', "v201605");
        $customerSyncService
= $user->GetService('CustomerSyncService', "v201605");


       
// Get an array of all campaign ids.
        $campaignIds
= array();
        $selector
= new \Selector();
        $selector
->fields = array('Id', 'Name', 'Status');
        $selector
->paging = new \Paging(0, 500);
        $selector
->predicates[] = new \Predicate('Status', 'IN', array('ENABLED'));
       
do {
            $page
= $campaignService->get($selector);
           
if (isset($page->entries)) {
               
foreach ($page->entries as $campaign) {
                   
//get all campaign id corresponding to its name
                    $campaignIds
[$campaign->id] = $campaign->name;
               
}
           
}
            $selector
->paging->startIndex += 500;
       
} while ($page->totalNumEntries > $selector->paging->startIndex);
        $activityGraphArr
= array();
       
// Set the date time range, from 24 hours ago until now.
        $dateTimeRange
= new \DateTimeRange();
       
//initialize the count to 0
       
if(!empty($campaignIds)){
       
//bug fixed: display account activity for 90 days instead of 12 weeks
       
try{
               
for ($i = 0; $i < 12; $i++) {
                $count
= 0;
               
//fetch data weekly.. so set date by subtracting the days from min nd max date
                $subDays
= 7 * $i;
                $fdate
= date('Y-m-d', strtotime('-' . $subDays . 'day', strtotime($fromDate)));
                $tdate
= date('Y-m-d', strtotime('-' . $subDays . 'day', strtotime($toDate)));
                $dateTimeRange
->min = date('Ymd his', strtotime($fdate));
                $dateTimeRange
->max = date('Ymd his', strtotime($tdate));


               
// Create selector.
               
//get customer acc setting from $customerSyncService
                $selector
= new \CustomerSyncSelector();
                $selector
->dateTimeRange = $dateTimeRange;
                $selector
->campaignIds = array_keys($campaignIds);


               
// Make the get request.
                $accountChanges
= $customerSyncService->get($selector);
               
if (isset($accountChanges)) {
                   
foreach ($accountChanges->changedCampaigns as $campaignChangeData) {
                       
if ($campaignChangeData->campaignChangeStatus != 'NEW') {
                           
//add all the changes to get the total number of times changes
                           
//are made
                            $count
+=!empty($campaignChangeData->removedAdExtensions) ?
                                    sizeOf
($campaignChangeData->removedAdExtensions) : 0;
                            $count
+=!empty($campaignChangeData->addedCampaignCriteria) ?
                                    sizeOf
($campaignChangeData->addedCampaignCriteria) : 0;
                            $count
+=!empty($campaignChangeData->removedCampaignCriteria) ?
                                    sizeOf
($campaignChangeData->removedCampaignCriteria) : 0;
                           
if (isset($campaignChangeData->changedAdGroups)) {
                               
foreach ($campaignChangeData->changedAdGroups as $adGroupChangeData) {
                                   
if ($adGroupChangeData->adGroupChangeStatus != 'NEW') {
                                         $count
+=!empty($adGroupChangeData->changedAds) ?
                                                sizeOf
($adGroupChangeData->changedAds) : 0;


                                   
}
                               
}
                           
}
                       
}
                   
}
                   
//push date and count into array
                    $graphArr
[0] = $fdate;
                    $graphArr
[1] = $count;
                    array_push
($activityGraphArr, $graphArr);
               
}
           
}
       
}catch (Exception $ex) {
            $this
->log($ex->getMessage(), "error");
       
}
       
}
   
return $activityGraphArr;
 
}



Reply all
Reply to author
Forward
0 new messages