Jeff,
I have already defined this job with required parameters for soap
headers.Please see my code below mentioned here. It prints "Jeff" that
I did for testing purpose. But it fails after that. It did not print
hello. I took this code from sample code that are available at Ad
words website in the sample code section for reportService. I just
changed startday and endDay as parameters only. That's the only change
I did and added my required parameter for soap header.

 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);

              Calendar startDay = Calendar.getInstance();             //here 
set as
today that I saw on adwords web site
              GregorianCalendar endDay = new GregorianCalendar(2037,
Calendar.DECEMBER,30); //here to set end date

              job.setStartDay(startDay);
              job.setEndDay(endDay);
              job.setSelectedColumns(new String[] {
                  "Campaign", "AdGroup", "Keyword", "KeywordStatus",
"KeywordMinCPC",
                  "KeywordDestUrlDisplay", "Impressions", "Clicks", "CTR",
                  "AveragePosition"});

              // Validate report.
              try {
                System.out.println("Jeff");                       //  till now
it is fine
                service.validateReportJob(job);                //fails here
           System.out.println("hello");
                // 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();
            }
          }
        }

Could you please help why it's not validating report ?===============>
service.validateReportJob(job);                //fails here
I did not make any change.I just called this API. I checked in the
code also.It should take job as input parameter that I did here.
Thanks
Rajni

On Jan 20, 2:56 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
wrote:
> My mistake--I always confuse Java and C# unless I pay close attention
> to the System.out vs. Console stuff. In any case, there's the Java
> client library that would be a better choice:
>
>  http://code.google.com/p/google-api-adwords-java/
>
> There's an example included with the Java client library for
> scheduling and downloading a report, which will be in XML format.
> You'll have to change some of the report options to match exactly what
> you're looking for, using this information as your guide:
>
>  http://code.google.com/intl/en/apis/adwords/docs/developer/DefinedRep...
>
> Cheers,
> -Jeff Posnick, AdWords API Team
>
> On Jan 20, 5:47 pm, raj <adp-...@adp.com> wrote:
>
> > My development environment is  java and axis. I have all the wsdls and
> > all the java classes. As per our last meeting in my company, it's
> > fixed that we need to develope all the code in java. Becuase we are
> > currently working in java side not in dot net side. My target is to
> > get .xml file for clicks, impressions, average position etc for
> > campaigns. That can be done either this way that I have found in other
> > ad words 
> > linkhttp://www.mail-archive.com/adwords-api@googlegroups.com/msg01351.html
> > . As we know getCampaignStats method contains clicks, impressions etc.
> > As you can see in my code below.
> > private static final String namespace = "https://adwords.google.com/
> > api/adwords/v12";
> > private static int[] campaignIds;
> > static Calendar endDay;
> > static Calendar startDay ;
>
> > public static void main(String[] args) throws Exception  {
> > try {
> > // Set up service connection.
> > CampaignInterface service = new CampaignServiceLocator
> > ().getCampaignService();
>
> > // 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);
> > StatsRecord[] campaigns = null;
> > // Get all campaigns.
> > campaigns = service.getCampaignStats(campaignIds,startDay,endDay);
> > for(int i = 0; i < 10;  i++)
> > {
> >         System.out.println("The value is " +campaigns[i].getClicks());
> >         System.out.println("The value is " +campaigns[i].getImpressions());
> >         System.out.println("The value is " +campaigns[i].getAveragePosition
> > ());
> >         System.out.println("The value is " +campaigns[i].getConversions());
> >         System.out.println("The value is " +campaigns[i].getCost());
> >         System.out.println("The value is " +campaigns[i].getConversionRate
> > ());}
> > } catch (ApiException e) {
>
> >         e.printStackTrace();} catch (RemoteException e) {
>
> >         e.printStackTrace();}
>
> > finally
> > {
>
> > }
> > }
> > }
>
> > OR
>
> >  The other way is ------>  You can either schedule a report using
> > the ReportService for a particular date and include the relevant
> > columns( clicks, impressions,average position).
>
> > AS per our requirement we need all these data in xml format. That is
> > only possible through ReportService.
> > When I ran the code that I send to you in my previous mail, I am
> > getting this error =======================>       Report job failed
> > validation due to the following error: "null".
> > Could you please help me to figure out why am I getting this error?
> > Thanks in advance
> > Raj
>
> > On Jan 20, 1:56 pm, AdWords API Advisor <adwordsapiadvi...@google.com>
> > wrote:
>
> > > Hello,
>
> > >  If you're just getting started with the AdWords API in C#, I'd
> > > recommend that you use the official .NET client library instead of
> > > trying to piece together the standalone pieces of sample code:
>
> > >  http://code.google.com/p/google-api-adwords-dotnet/
>
> > >  The client library will make it much easier to do things like
> > > schedule reports, and it includes samples written against the client
> > > library illustrating how to do that.
>
> > > Cheers,
> > > -Jeff Posnick, AdWords API Team
>
> > > On Jan 20, 12:02 pm, raj <adp-...@adp.com> wrote:
>
> > > > 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();
> > > >             }
> > > >           }
> > > >         }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"AdWords API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to 
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/adwords-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to