1
votes

I am trying to query the adwords api (v201603) and am using/extending the Java examples provided.

The problem I am encountering is being able to specify a specific date to download the report data for the CLICK_PERFORMANCE_REPORT report. This report is restricted to returning a single days worth of data at a time (for up to the last 90 days).

I can get todays and yesterdays data using the specifiers : ReportDefinitionDateRangeType.TODAY and ReportDefinitionDateRangeType.YESTERDAY, but what I really need to do is be able to specify a specific date within the last 90 days in order to get as much historical data as possible.

I have tried the following:

    DateRange dr = new DateRange();
    dr.setMin("20160401");
    dr.setMax("20160402");
    selector.setDateRange(dr);

    reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.CUSTOM_DATE);
    reportDefinition.setReportType(ReportDefinitionReportType.CLICK_PERFORMANCE_REPORT);
    reportDefinition.setDownloadFormat(DownloadFormat.CSV);

Both with and without the custom date specifier - and either gives the following error:

Report was not downloaded due to: HTTP Response Code: 400, Trigger: A single day DateRange is required for reportType: CLICK_PERFORMANCE_REPORT, Type: ReportDefinitionError.INVALID_DATE_RANGE_FOR_REPORT

Any help much appreciated, thanks in advance

2
Did you try with the same date?fabrigm
So simple - yet so correct. Bashing my head against the wall with this and too many other things to see the simple solution. Thank you. This DOES need to be run with the CUSTOM_DATE date range type, otherwise the error occurs.Neil Stoneman
Got the same issue but using python. @fabrigm - what do you mean by "try with the same date?"AK91
@AK91 if you want one day, put that date in both, the start and the end.fabrigm

2 Answers

3
votes

You're going to have to use DURING and the same date string.

... + 'DURING 20161004,20161004';
0
votes

Single Day Iterator for AdWords Scripts CLICK_PERFORMANCE_REPORT:

var start = new Date("12/01/2016");
var end = new Date("12/18/2016");

while(start < end){

   var newDate = start.setDate(start.getDate() + 1);
   start = new Date(newDate);
   singleDay = start.toISOString().substring(0, 10).replace(/-/g,"");
   console.log(singleDay);

}

Utilities.formatDate(start, timeZone, "yyyyMMdd"); formats date object as an 8-digit integer, so:

singleDay = Utilities.formatDate(start, timeZone, "yyyyMMdd");

Use singleDay in 'DURING ' + singleDay + ',' + singleDay);

Working with Dates and Times #Reporting — AdWords Scripts