Zero Impressions Issue: dateRange is expected

122 views
Skip to first unread message

Danny

unread,
Jul 6, 2017, 6:50:53 PM7/6/17
to AdWords API Forum
Hi

I'm trying to make a call on the CRITERIA_PERFORMANCE_REPORT and AD_PERFORMANCE_REPORT report, but I keep getting this error,

[Google\AdsApi\AdWords\v201609\cm\ApiException]
  Details: [fieldPath: ; trigger: Invalid ReportDefinition Xml: cvc-complex-type.2.4.b: The content of element 'reportDefinition' is not complete. One of '{"https://adwords.goo
  gle.com/api/adwords/cm/v201609":dateRangeType}' is expected.; errorString: ReportDownloadError.INVALID_REPORT_DEFINITION_XML]

These are my request headers and response,

[2017-07-06 22:24:04] AW_REPORT_DOWNLOADER.NOTICE: >>>>>>>>
POST /api/adwords/reportdownload/v201609 HTTP/1.1
Authorization: REDACTED
User-Agent: GuzzleHttp/6.2.1 curl/7.47.0 PHP/7.1.0-2+deb.sury.org~xenial+1
Content-Type: application/x-www-form-urlencoded
Host: adwords.google.com
developerToken: XXXXXXXXXX // this has been masked
clientCustomerId: XXXXXXXXXX // this has been masked
skipReportHeader: false
skipColumnHeader: false
skipReportSummary: false
useRawEnumValues: false
includeZeroImpressions: true
__rdxml=<?xml version="1.0"?>
<reportDefinition><selector><fields>AdGroupId</fields><fields>AdGroupName</fields><fields>AdGroupStatus</fields><fields>CampaignId</fields><fields>CampaignName</fields><fields>CampaignStatus</fields><fields>Criteria</fields><fields>CriteriaType</fields><fields>FinalUrls</fields><fields>CustomerDescriptiveName</fields><fields>ExternalCustomerId</fields><predicates><field>AdGroupStatus</field><operator>IN</operator><values>ENABLED</values></predicates><predicates><field>CampaignStatus</field><operator>IN</operator><values>ENABLED</values></predicates><predicates><field>FinalUrls</field><operator>NOT_EQUALS</operator><values></values></predicates></selector><reportName>Criteria Performance Report #595eb884247f4</reportName><reportType>CRITERIA_PERFORMANCE_REPORT</reportType></reportDefinition>
<<<<<<<<
HTTP/1.1 400 Bad Request
Content-Type: text/xml
Date: Thu, 06 Jul 2017 22:24:04 GMT
Expires: Thu, 06 Jul 2017 22:24:04 GMT
Cache-Control: private, max-age=0
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
Server: GSE
Alt-Svc: quic=":443"; ma=2592000; v="39,38,37,36,35"
Accept-Ranges: none
Vary: Accept-Encoding
Connection: close

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

  • All my selector fields are attributes
  • All my predicate fields are attributes
  • includeZeroImpressions is set to true in header
  • My request doesn't include any date range
Not quite sure what's the problem?

What I'm trying to do is essentially get the structure of keywords and ads of the account. Also, which report should I be using to get sitelinks structure?

Peter Oliquino

unread,
Jul 7, 2017, 2:06:45 AM7/7/17
to AdWords API Forum
Hi Danny,

Using the v201609 version of the AdWords API and the report definition you provided, I was not able to reproduce the error in my end. Could you also confirm if you are using any of the client library sample codes (other languages are also available in the link) when generating your report?

Additionally, if you wish to retrieve Sitelink level information, then I would recommend that you also use the Placeholder FeedItem Report and the PlaceholderType = 1 as filter.

Best regards,
Peter
AdWords API Team

Danny

unread,
Jul 7, 2017, 2:08:10 AM7/7/17
to AdWords API Forum
When I add a date range, it seems to work. However, I don't want it to be dependent on the date range as I'm only interested in the structure of the account.

$this->report_definition->setDateRangeType(ReportDefinitionDateRangeType::TODAY);

Danny

unread,
Jul 7, 2017, 2:12:46 AM7/7/17
to AdWords API Forum
Yes I'm using examples (not copy and paste though) from client library sample code. As I mentioned earlier, it works when I add a dateRange but I don't want it to be dependent on this as I'm after the structure.

Is there anything wrong with my SOAP?

Danny

unread,
Jul 7, 2017, 3:41:45 AM7/7/17
to AdWords API Forum
I tested it using AWQL using the example found at https://developers.google.com/adwords/api/docs/guides/zeroimpression-structure-reports#retrieving_ad_group_criteria and it seems to work fine.

        $downloader = new ReportDownloader($this->session);
        $query = 'SELECT AdGroupId, Id, CriteriaType, Criteria, IsNegative FROM CRITERIA_PERFORMANCE_REPORT';
        $result = $downloader->downloadReportWithAwql($query, DownloadFormat::CSV);
        $file_path = sprintf('%s.csv', tempnam(base_path('downloads'), 'download-report-'));
        $result->saveToFile($file_path);

Does this not work using Selector and ReportDefinition as it seems to be always expecting dateRangeType in the SOAP request?

Peter Oliquino

unread,
Jul 7, 2017, 5:57:24 AM7/7/17
to AdWords API Forum
Hi Danny,

My apologies for missing this out earlier as I did not realize that you used the Selector and ReportDefinition classes. This said, as per this documentation (bottom of the table), the dateRangeType type is required. However, if you use the AWQL only approach your query should work correctly without defining a date range.

Danny

unread,
Jul 7, 2017, 12:03:42 PM7/7/17
to AdWords API Forum
Ok thanks for the clarification. The documentation should really mention that specifically that leaving out the dateRangeType is only for the AWQL approach (not Selector & ReportDefinition).

However, I prefer to use the Selector & ReportDefinition classes. Does it matter what dateRangeType you use then if you're planning to pull out the structure?

Peter Oliquino

unread,
Jul 9, 2017, 11:21:09 PM7/9/17
to AdWords API Forum
Hi Danny,

As for specifying a dateRangeType (whether its a custom date range or a pre-defined date range), it should only affect the volume of records that you wish to pull, meaning, only the data that have generated performance statistics during that period will be returned.

Danny

unread,
Jul 10, 2017, 2:59:14 PM7/10/17
to AdWords API Forum
Ok thanks.

Whenever the report is downloaded, for some reason it always generates an empty text file, along with the csv file. I'm using the saveToFile method. What's the purpose of this file and is there a way to prevent it from downloading?

Also looking at the Placeholder Feed Item report, seems like there's no attribute to inform you where the sitelinks are attached to (e.g. account, campaign, adgroup level). How do you determine this?

Peter Oliquino

unread,
Jul 11, 2017, 12:16:07 AM7/11/17
to AdWords API Forum
Hi Danny,

Being that you mentioned you are getting blank files when you download, could you confirm if this issue still persists? If yes, please send your complete report definition, the generated blank report file, your clientCustomerId and any error messages if available so I can further investigate. You may reply using Reply privately to author.

As for the saveToFile method, it allows you to download a copy of the file of your chosen format into your local. However, if you wish not to save these files, you may download the report as a string (please see the getAsString() example in the linked example).

For the Placeholder Feed Item Report, the AdGroupIdCampaignId, and ExternalCustomerId fields are available to know which ad group, campaign, and account they belong but the information as to which entity level they are an extension of is not available through this report. You will need to use either the AdGroupExtensionSettingService.getCampaignExtensionSettingService.get, or the CustomerExtensionSettingService.get to determine so.

Thanks and regards,
Peter
AdWords API Team
Reply all
Reply to author
Forward
0 new messages