Very sorry, I posted the wrong code. Here it is: package v201206;
import com.google.api.adwords.lib.AdWordsServiceLogger; import com.google.api.adwords.lib.AdWordsUser; import com.google.api.adwords.lib.utils.v201206.ReportDownloadResponse; import com.google.api.adwords.lib.utils.v201206.ReportUtils; import com.google.api.adwords.v201206.jaxb.cm.DateRange; import com.google.api.adwords.v201206.jaxb.cm.DownloadFormat; import com.google.api.adwords.v201206.jaxb.cm.ReportDefinition; import com.google.api.adwords.v201206.jaxb.cm.ReportDefinitionDateRangeType; import com.google.api.adwords.v201206.jaxb.cm.ReportDefinitionReportType; import com.google.api.adwords.v201206.jaxb.cm.Selector; import java.io.File; import java.io.FileOutputStream; import java.net.HttpURLConnection; import java.util.List; public class mcDownloadCallMetricsReport { public static void main(String[] args) { try { // Log SOAP XML request and response. AdWordsServiceLogger.log(); // Get AdWordsUser from "~/adwords.properties". AdWordsUser user = new AdWordsUser(); // Location to download report to. String reportFile = "/tmp/report.csv"; // Create selector. Selector selector = new Selector(); List<String> fields = selector.getFields(); fields.add("AdGroupId"); fields.add("AdGroupName"); fields.add("CallDuration"); /* fields.add("CallEndTime"); fields.add("CallerNationalDesignatedCode"); fields.add("CallStartTime"); fields.add("CallStatus"); fields.add("CampaignId"); fields.add("CampaignName"); */ // Create report definition. ReportDefinition reportDefinition = new ReportDefinition(); reportDefinition.setReportName("Call metrics report #" + System.currentTimeMillis()); reportDefinition.setDateRangeType(ReportDefinitionDateRangeType. LAST_7_DAYS); /* DateRange dateRange = new DateRange(); dateRange.setMin("20120101"); dateRange.setMax("20120930"); selector.setDateRange(dateRange); */ reportDefinition.setReportType(ReportDefinitionReportType. CALL_METRICS_CALL_DETAILS_REPORT); reportDefinition.setDownloadFormat(DownloadFormat.CSV); reportDefinition.setIncludeZeroImpressions(true); reportDefinition.setSelector(selector); FileOutputStream fos = new FileOutputStream(new File(reportFile)); ReportDownloadResponse response = ReportUtils.downloadReport(user, reportDefinition, fos); if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) { System.out.println("Report successfully downloaded: " + reportFile); } else { System.out.println("Report was not downloaded. " + response.getHttpStatus() + ": " + response.getHttpResponseMessage()); } } catch (Exception e) { e.printStackTrace(); } } } On Friday, October 5, 2012 9:38:11 AM UTC-4, Michael Caldwell wrote: > > Hi Google AdWords API team: > > When I run the DownloadAdHocReport.java sample in the v201206 code > examples download, just substituting for > the CALL_METRICS_CALL_DETAILS_REPORT report type and appropriate Selector > fields, I get this: > > Report was not downloaded. 500: !!!1|||-1|||BetaError.BETA_FEATURE @ > selector.reportDefinition.reportType??? > > I'm using the Sandbox, not production AdWords, as this is just a > development effort at this point. > > Did the report fail because it's Beta and therefore not available in the > API, or did it fail because it's Beta and therefore not available using the > Sandbox API, or am I doing something else wrong? My boss and stakeholders > would be very happy to have this report :-) > > Here's the full code (it's your code really - great code samples BTW! - > just with the simple changes I needed to run the Call Metrics needed) : > > // Copyright 2012 Google Inc. All Rights Reserved. > > // > > // Licensed under the Apache License, Version 2.0 (the "License"); > > // you may not use this file except in compliance with the License. > > // You may obtain a copy of the License at > > // > > // http://www.apache.org/licenses/LICENSE-2.0 > > // > > // Unless required by applicable law or agreed to in writing, software > > // distributed under the License is distributed on an "AS IS" BASIS, > > // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > > // See the License for the specific language governing permissions and > > // limitations under the License. > > > package v201206; > > > import com.google.api.adwords.lib.AdWordsServiceLogger; > > import com.google.api.adwords.lib.AdWordsUser; > > import com.google.api.adwords.lib.utils.v201206.ReportDownloadResponse; > > import com.google.api.adwords.lib.utils.v201206.ReportUtils; > > import com.google.api.adwords.v201206.jaxb.cm.DownloadFormat; > > import com.google.api.adwords.v201206.jaxb.cm.ReportDefinition; > > import > com.google.api.adwords.v201206.jaxb.cm.ReportDefinitionDateRangeType; > > import com.google.api.adwords.v201206.jaxb.cm.ReportDefinitionReportType; > > import com.google.api.adwords.v201206.jaxb.cm.Selector; > > > import java.io.File; > > import java.io.FileOutputStream; > > import java.net.HttpURLConnection; > > import java.util.List; > > > /** > > * This example adds a keywords performance report. To get ad groups, run > > * GetAllAdGroups.java. To get report columns, run GetReportColumns.java. > > * > > * Tags: ReportDefinitionService.mutate > > * > > * @category adx-exclude > > * @author api.kwin...@gmail.com (Kevin Winter) > > */ > > public class DownloadAdHocReport { > > public static void main(String[] args) { > > try { > > // Log SOAP XML request and response. > > AdWordsServiceLogger.log(); > > > // Get AdWordsUser from "~/adwords.properties". > > AdWordsUser user = new AdWordsUser(); > > > // Location to download report to. > > String reportFile = "/tmp/report.csv"; > > > // Create selector. > > Selector selector = new Selector(); > > List<String> fields = selector.getFields(); > > fields.add("AdGroupId"); > > fields.add("Id"); > > fields.add("KeywordText"); > > fields.add("KeywordMatchType"); > > fields.add("Impressions"); > > fields.add("Clicks"); > > fields.add("Cost"); > > > // Create report definition. > > ReportDefinition reportDefinition = new ReportDefinition(); > > reportDefinition.setReportName("Keywords performance report #" + > System.currentTimeMillis()); > > > reportDefinition.setDateRangeType(ReportDefinitionDateRangeType.YESTERDAY); > > > reportDefinition.setReportType(ReportDefinitionReportType.KEYWORDS_PERFORMANCE_REPORT); > > reportDefinition.setDownloadFormat(DownloadFormat.CSV); > > reportDefinition.setIncludeZeroImpressions(false); > > reportDefinition.setSelector(selector); > > > FileOutputStream fos = new FileOutputStream(new File(reportFile)); > > ReportDownloadResponse response = ReportUtils.downloadReport(user, > reportDefinition, fos); > > if (response.getHttpStatus() == HttpURLConnection.HTTP_OK) { > > System.out.println("Report successfully downloaded: " + > reportFile); > > } else { > > System.out.println("Report was not downloaded. " + > response.getHttpStatus() + ": " > > + response.getHttpResponseMessage()); > > } > > } catch (Exception e) { > > e.printStackTrace(); > > } > > } > > } > > > > -- =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ Also find us on our blog and discussion group: http://adwordsapi.blogspot.com http://groups.google.com/group/adwords-api =~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~ 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