error UNEXPECTED_INTERNAL_API_ERROR while fetching account activity data

30 views
Skip to first unread message

Pallavi Sharma

unread,
Jan 9, 2017, 10:05:45 AM1/9/17
to AdWords API Forum
hi, 
I am using the  CustomerSyncService api to fetch account activity (v201605)
i'm getting the error UNEXPECTED_INTERNAL_API_ERROR while fetching account activity . This happens only for one client, for the rest of  clients this api is working fine. It was working fine for this client also till 6 jan bt today i am unable to fetch data for one specific client..

error which i got is :
[SoapFault] [InternalApiError.UNEXPECTED_INTERNAL_API_ERROR @ com.google.ads.api.services.common.error.InternalApiError.<init>(InternalApiErro]

any reasn for this ???
code is: 
 
  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', ADWORD_VERSION);
        $customerSyncService
= $user->GetService('CustomerSyncService', ADWORD_VERSION);


       
// 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;
 
}



Vishal Vinayak (Adwords API Team)

unread,
Jan 9, 2017, 4:03:56 PM1/9/17
to AdWords API Forum
Hi Pallavi,

Could you please send me the SOAP XML request & response logs for the API call that returned the UNEXPECTED_INTERNAL_API_ERROR?

Regards,
Vishal Vinayak, AdWords API Team
Reply all
Reply to author
Forward
0 new messages