How to specify custom date range in google adwords selector properly with python?
My goal is to get ACCOUNT_PERFORMANCE_REPORT
with custom date range.
I've tried
oauth2_client = GoogleRefreshTokenClient(self.client_id, self.client_secret, refresh_token) adwords_client = AdWordsClient(developer_token, oauth2_client, self.user_agent) report_downloader = client.GetReportDownloader(version='v201809') report={ 'reportName': 'Google xxx ACCOUNT_PERFORMANCE_REPORT', 'dateRangeType': 'CUSTOM_DATE', 'reportType': 'ACCOUNT_PERFORMANCE_REPORT', 'downloadFormat': 'CSV', 'selector': { 'fields': ['CustomerDescriptiveName', 'Date', 'Cost'], 'dateRange': '20200501,20201031' } }
And got
Request Summary: { 'clientCustomerId': 'None', 'includeZeroImpressions': 'True', 'server': 'adwords.google.com', 'skipColumnHeader': 'False', 'skipReportHeader': 'False', 'skipReportSummary': 'False', 'isError': True, 'errorMessage': '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><reportDownload Error><ApiError><type>ReportDownloadError.INVALID_REPORT_DEFINITION_XML</type><trigger>Invalid ReportDefinition Xml: DateError.INVALID_STRING_DATE @ </t rigger><fieldPath></fieldPath></ApiError></reportDownloadError>' }
but when i use
report= { 'reportName': 'Google xxx ACCOUNT_PERFORMANCE_REPORT', 'dateRangeType': 'LAST_7_DAYS', 'reportType': 'ACCOUNT_PERFORMANCE_REPORT', 'downloadFormat': 'CSV', 'selector': { 'fields': ['CustomerDescriptiveName', 'Date', 'Cost'] } }
it's ok
The question is: How to specify custom dateRange
range in selector
properly?
While reading the documentation, I found the answer to my question. I've made a mistake when used awql syntax here.
The proper dateRange selector should have been:
'dateRange': {'min': '20200501', 'max': '20201031'}