Hi,
I am trying to run report to get clicks , impressions. I tried to
do with ReportService that I saw in the sample code. But I when ran
the report I am getting this error "Report job failed validation
due to the following error: "null". "
Could you please tell me why am I getting this error?
Here is my code:-
private static final String namespace =
"
https://adwords.google.com/api/adwords/v12";
public static void main(String[] args) {
try {
// Set up service connection.
ReportInterface service =
new ReportServiceLocator().getReportService();
// Define SOAP headers.
((Stub) service).setHeader(namespace, "email", email);
((Stub) service).setHeader(namespace, "password", password);
((Stub) service).setHeader(namespace, "clientEmail",
clientEmail);
((Stub) service).setHeader(namespace, "useragent", useragent);
((Stub) service).setHeader(namespace, "developerToken",
developerToken);
((Stub) service).setHeader(
namespace, "applicationToken", applicationToken);
// Create report job structure.
DefinedReportJob job = new DefinedReportJob();
job.setSelectedReportType("Keyword");
job.setName("Sample Keyword Report");
job.setAggregationTypes(new String[] {"Summary"});
job.setAdWordsType(AdWordsType.SearchOnly);
job.setKeywordType(KeywordType.Broad);
GregorianCalendar startDay = new GregorianCalendar(2008,
Calendar.OCTOBER,1);
GregorianCalendar endDay = new GregorianCalendar(2008,
Calendar.DECEMBER,31);
job.setStartDay(startDay);
job.setEndDay(endDay);
job.setSelectedColumns(new String[] {
"Campaign", "AdGroup", "Keyword", "KeywordStatus",
"KeywordMinCPC",
"KeywordDestUrlDisplay", "Impressions", "Clicks", "CTR",
"AveragePosition"});
// Validate report.
try {
service.validateReportJob(job);
// Schedule report.
long jobId = service.scheduleReportJob(job);
// Wait for report to finish.
ReportJobStatus status = service.getReportJobStatus(jobId);
while(status != ReportJobStatus.Completed &&
status != ReportJobStatus.Failed) {
System.out.println(
"Report job status is \"" + status.getValue() + "\".");
try {
Thread.sleep(30000);
} catch(InterruptedException e) {}
status = service.getReportJobStatus(jobId);
}
if(status == ReportJobStatus.Failed) {
System.out.println("Report job generation failed.");
System.exit(0);
}
// Download report.
String url = service.getGzipReportDownloadUrl(jobId);
System.out.println("Report is available at \"" + url +
"\".");
} catch (ApiException e) {
System.out.println(
"Report job failed validation due to the following error:
\""
+ e.getMessage() + "\".");
}
} catch(Exception e) {
e.printStackTrace();
}
}
}