DownloadCriteriaReportWithSelector Error

362 views
Skip to first unread message

Dominik Raffetseder

unread,
Feb 12, 2018, 6:35:24 AM2/12/18
to AdWords API Forum
I want to do some reporting, but always get this error. How can i solve?

class DownloadCriteriaReportWithSelector {

  public static function runExample(AdWordsSession $session, $filePath) {
    // Create selector.
    $selector = new Selector();
    $selector->setFields(['CampaignId']);

    // Use a predicate to filter out paused criteria (this is optional).
    $selector->setPredicates([
        new Predicate('Status', PredicateOperator::NOT_IN, ['PAUSED'])]);

    // Create report definition.
    $reportDefinition = new ReportDefinition();
    $reportDefinition->setSelector($selector);
    $reportDefinition->setReportName(
        'Criteria performance report #' . uniqid());
    $reportDefinition->setDateRangeType(
        ReportDefinitionDateRangeType::LAST_7_DAYS);
    $reportDefinition->setReportType(
        ReportDefinitionReportType::CRITERIA_PERFORMANCE_REPORT);
    $reportDefinition->setDownloadFormat(DownloadFormat::CSV);

    // Download report.
    $reportDownloader = new ReportDownloader($session);
    // Optional: If you need to adjust report settings just for this one
    // request, you can create and supply the settings override here. Otherwise,
    // default values from the configuration file (adsapi_php.ini) are used.
    $reportSettingsOverride = (new ReportSettingsBuilder())
        ->includeZeroImpressions(false)
        ->build();
    $reportDownloadResult = $reportDownloader->downloadReport(
        $reportDefinition, $reportSettingsOverride);
    $reportDownloadResult->saveToFile($filePath);
    printf("Report with name '%s' was downloaded to '%s'.\n",
        $reportDefinition->getReportName(), $filePath);
  }

  public static function main() {
    // Generate a refreshable OAuth2 credential for authentication.
    $oAuth2Credential = (new OAuth2TokenBuilder())
        ->fromFile()
        ->build();

    // See: AdWordsSessionBuilder for setting a client customer ID that is
    // different from that specified in your adsapi_php.ini file.
    // Construct an API session configured from a properties file and the OAuth2
    // credentials above.
    $session = (new AdWordsSessionBuilder())
        ->fromFile()
        ->withOAuth2Credential($oAuth2Credential)
        ->build();

    $filePath = sprintf(
        '%s.csv',
        tempnam(sys_get_temp_dir(), 'criteria-report-')
    );
    self::runExample($session, $filePath);
  }
}

DownloadCriteriaReportWithSelector::main();



Following the error:

Dominiks-iMac:adwords Dominik$ php DownloadCriteriaReportWithSelector.php

[2018-02-12 12:22:51] AW_REPORT_DOWNLOADER.WARNING: clientCustomerId=608-580-1167 ###### (AwApi-PHP, googleads-php-lib/32.1.0, PHP/7.1.11, GuzzleHttp/6.2.1, curl/7.45.0) "POST /api/adwords/reportdownload/v201710 HTTP/1.1" Status: 400   

[2018-02-12 12:22:51] AW_REPORT_DOWNLOADER.NOTICE: Request:

POST /api/adwords/reportdownload/v201710 HTTP/1.1

Content-Type: application/x-www-form-urlencoded

Host: adwords.google.com

Authorization: REDACTED

developerToken: REDACTED

clientCustomerId: #########

User-Agent: ######## (AwApi-PHP, googleads-php-lib/32.1.0, PHP/7.1.11, GuzzleHttp/6.2.1, curl/7.45.0)

skipReportHeader: false

skipColumnHeader: false

skipReportSummary: false

useRawEnumValues: false

includeZeroImpressions: false


__rdxml=<?xml version="1.0"?>

<reportDefinition><selector><fields>CampaignId</fields><predicates><field>Status</field><operator>NOT_IN</operator><values>PAUSED</values></predicates></selector><reportName>Criteria performance report #5a81790a0c817</reportName><reportType>CRITERIA_PERFORMANCE_REPORT</reportType><dateRangeType>LAST_7_DAYS</dateRangeType><downloadFormat>CSV</downloadFormat></reportDefinition>



Response:

REDACTED REPORT DATA

--------

Error:

Client error: `POST https://adwords.google.com/api/adwords/reportdownload/v201710` resulted in a `400 Bad Request` response

  

PHP Fatal error:  Uncaught Google\AdsApi\AdWords\v201710\cm\ApiException: Details: [fieldPath: selector.reportDefinition; trigger: ; errorString: ReportDefinitionError.CUSTOMER_SERVING_TYPE_REPORT_MISMATCH] in /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/googleads-php-lib/src/Google/AdsApi/AdWords/Reporting/v201710/ReportDownloader.php:168

Stack trace:

#0 /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/googleads-php-lib/src/Google/AdsApi/AdWords/Reporting/v201710/ReportDownloader.php(106): Google\AdsApi\AdWords\Reporting\v201710\ReportDownloader->makeReportRequest(Array)

#1 /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/DownloadCriteriaReportWithSelector.php(68): Google\AdsApi\AdWords\Reporting\v201710\ReportDownloader->downloadReport(Object(Google\AdsApi\AdWords\Reporting\v201710\ReportDefinition), Object(Google\AdsApi\AdWords\ReportSettings))

#2 /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/DownloadCriteriaReportWithSelector.php(93): Google\AdsApi\Examples\AdWords\v201710\Reporting\DownloadCriteriaReportWithSel in /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/googleads-php-lib/src/Google/AdsApi/AdWords/Reporting/v201710/ReportDownloader.php on line 168


Fatal error: Uncaught Google\AdsApi\AdWords\v201710\cm\ApiException: Details: [fieldPath: selector.reportDefinition; trigger: ; errorString: ReportDefinitionError.CUSTOMER_SERVING_TYPE_REPORT_MISMATCH] in /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/googleads-php-lib/src/Google/AdsApi/AdWords/Reporting/v201710/ReportDownloader.php:168

Stack trace:

#0 /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/googleads-php-lib/src/Google/AdsApi/AdWords/Reporting/v201710/ReportDownloader.php(106): Google\AdsApi\AdWords\Reporting\v201710\ReportDownloader->makeReportRequest(Array)

#1 /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/DownloadCriteriaReportWithSelector.php(68): Google\AdsApi\AdWords\Reporting\v201710\ReportDownloader->downloadReport(Object(Google\AdsApi\AdWords\Reporting\v201710\ReportDefinition), Object(Google\AdsApi\AdWords\ReportSettings))

#2 /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/DownloadCriteriaReportWithSelector.php(93): Google\AdsApi\Examples\AdWords\v201710\Reporting\DownloadCriteriaReportWithSel in /Applications/XAMPP/xamppfiles/htdocs/crm/adwords/googleads-php-lib/src/Google/AdsApi/AdWords/Reporting/v201710/ReportDownloader.php on line 168



How can i solve this?



Milind Sankeshware (AdWords API Team)

unread,
Feb 12, 2018, 12:04:57 PM2/12/18
to AdWords API Forum
Hi Dominik,

I see that you are getting CUSTOMER_SERVING_TYPE_REPORT_MISMATCH while trying to run the report. It is because you are trying to run a report against a manager account. Reports can be obtained only at the non-manager account level. In your case, you are using manager account id 608-580-1167. Could you please rerun the report with non-manager account and let me know how it goes?

Thanks,
Milind, AdWords API Team.

Dominik Raffetseder

unread,
Feb 12, 2018, 12:50:54 PM2/12/18
to AdWords API Forum
Is this a new problem?
In Version 201702 it worked in that way?
its complicated to do it for each account at its own?

Milind Sankeshware (AdWords API Team)

unread,
Feb 12, 2018, 3:19:42 PM2/12/18
to AdWords API Forum
Hi Dominik,

In version 201702, the behavior of this report functionality is same as in version 201710. To obtain the report, you have to run against the non-manager account. The ManagedCustomerService can be used to get account information, and if ManagedCustomer.canManageClients is true then the account is a manager account. Let me know if you have further questions.

Dominik Raffetseder

unread,
Feb 14, 2018, 7:43:36 AM2/14/18
to AdWords API Forum
Okay, is working now.
But when i do this again, i get always this error:

PHP Parse error:  syntax error, unexpected ':', expecting ';' or '{' in /usr/share/nginx/www/adwords/googleads-php-lib/vendor/symfony/serializer/Normalizer/GetSetMethodNormalizer.php on line 59


Milind Sankeshware (AdWords API Team)

unread,
Feb 14, 2018, 12:24:16 PM2/14/18
to AdWords API Forum
Hi Dominik,

PHP 5.5.9 and higher is a requirement for the new PHP client library. Please refer this guide for more details. Could you please update PHP version and check? Let me know if you have any further question.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages