$selector = new Selector();
$selector->setFields(
[
'AccountDescriptiveName',
'Date',
'ExternalCustomerId',
'AccountCurrencyCode',
'Impressions',
'Clicks',
'Ctr',
'AverageCpc',
'Cost',
'Conversions',
'CostPerConversion',
'ConversionValue',
]
);
$selector->setOrdering(
[
'AccountDescriptiveName',
'Date',
'ExternalCustomerId',
]
);
$reportDefinition = new ReportDefinition();
$reportDefinition->setSelector($selector);
$reportDefinition->setDateRangeType(
ReportDefinitionDateRangeType::THIS_MONTH
);
$reportDefinition->setReportType(
ReportDefinitionReportType::ACCOUNT_PERFORMANCE_REPORT
);
$reportDefinition->setDownloadFormat(DownloadFormat::CSVFOREXCEL);
Error:Client error: `POST https://adwords.google.com/api/adwords/reportdownload/v201809` resulted in a `400 Bad Request` response
[2020-02-20 09:33:38] AW_REPORT_DOWNLOADER.WARNING: clientCustomerId=[clientCustomerId] [userAgent] (AwApi-PHP, googleads-php-lib/44.0.0, PHP/7.3.11, GuzzleHttp/6.5.1, curl/7.61.1) "POST /api/adwords/reportdownload/v201809 HTTP/1.1" Status: 400[2020-02-20 09:33:38] AW_REPORT_DOWNLOADER.NOTICE: Request:POST /api/adwords/reportdownload/v201809 HTTP/1.1Content-Type: application/x-www-form-urlencodedHost: adwords.google.comAuthorization: REDACTEDdeveloperToken: REDACTEDclientCustomerId: [clientCustomerId]User-Agent: [User-Agent] (AwApi-PHP, googleads-php-lib/44.0.0, PHP/7.3.11, GuzzleHttp/6.5.1, curl/7.61.1)skipReportHeader: trueskipColumnHeader: trueskipReportSummary: trueuseRawEnumValues: falseincludeZeroImpressions: false
__rdxml=<?xml version="1.0"?><reportDefinition><selector><fields>AccountDescriptiveName</fields><fields>Date</fields><fields>ExternalCustomerId</fields><fields>AccountCurrencyCode</fields><fields>Impressions</fields><fields>Clicks</fields><fields>Ctr</fields><fields>AverageCpc</fields><fields>Cost</fields><fields>Conversions</fields><fields>CostPerConversion</fields><fields>ConversionValue</fields><ordering>AccountDescriptiveName</ordering><ordering>Date</ordering><ordering>ExternalCustomerId</ordering></selector><reportType>ACCOUNT_PERFORMANCE_REPORT</reportType><dateRangeType>THIS_MONTH</dateRangeType><downloadFormat>CSVFOREXCEL</downloadFormat></reportDefinition>
Response:REDACTED REPORT DATAHello,
Thank you for reaching out. I took a closer look into your report query and found that you are trying to set the ordering in your report query. Please note, the ORDER BY clause is disallowed in report calls. Please refer to this guide for more details on the formal grammar of AdWords Query Language. Could you please remove the ordering and retry your request? If the issue persists, could you please share the report definition along with the client customer id for further investigation?
P.S. Please use Reply privately to author option while sharing the details.
Regards,
Nikisha Patel, Google Ads API Team
$reportDefinition->setReportName('Custom ADGROUP_PERFORMANCE_REPORT');