我正在尝试从 Bing Ads 文档运行基本报告下载示例,并且我设法通过更改get<REPORT_TYPE>ReportRequest()
方法来修改示例代码以下载其他几种报告类型。
我正在努力解决的一种报告类型是预算摘要报告。
我创建这样的报告请求:
private static ReportRequest getBudgetSummaryReportRequest(){
BudgetSummaryReportRequest report = new BudgetSummaryReportRequest();
report.setFormat(ReportFormat.CSV);
report.setReportName("My Budget Summary Report");
report.setReturnOnlyCompleteData(false);
ArrayOflong accountIds = new ArrayOflong();
accountIds.getLongs().add(authorizationData.getAccountId());
report.setScope(new AccountThroughCampaignReportScope());
report.getScope().setAccountIds(accountIds);
ArrayOfCampaignReportScope c = new ArrayOfCampaignReportScope();
CampaignReportScope cc = new CampaignReportScope();
cc.setAccountId(authorizationData.getAccountId());
cc.setCampaignId(<MY_CAMPAIGN_ID>);
c.getCampaignReportScopes().add(cc);
report.getScope().setCampaigns(c);
report.setTime(new BudgetSummaryReportTime());
report.getTime().setPredefinedTime(BudgetSummaryReportTimePeriod.TODAY);
ArrayOfBudgetSummaryReportColumn budgetSummaryReportColumns = new ArrayOfBudgetSummaryReportColumn();
budgetSummaryReportColumns.getBudgetSummaryReportColumns().add(BudgetSummaryReportColumn.ACCOUNT_ID);
budgetSummaryReportColumns.getBudgetSummaryReportColumns().add(BudgetSummaryReportColumn.CAMPAIGN_ID);
budgetSummaryReportColumns.getBudgetSummaryReportColumns().add(BudgetSummaryReportColumn.DATE);
budgetSummaryReportColumns.getBudgetSummaryReportColumns().add(BudgetSummaryReportColumn.CURRENCY_CODE);
budgetSummaryReportColumns.getBudgetSummaryReportColumns().add(BudgetSummaryReportColumn.MONTHLY_BUDGET);
budgetSummaryReportColumns.getBudgetSummaryReportColumns().add(BudgetSummaryReportColumn.MONTH_TO_DATE_SPEND);
budgetSummaryReportColumns.getBudgetSummaryReportColumns().add(BudgetSummaryReportColumn.DAILY_SPEND);
return report;
}
然后ReportRequest
在 main 方法中使用该对象(参见reportRequest
示例中的字段)。但无论我做什么,当我尝试运行它时,总是会出现以下错误:
java.util.concurrent.ExecutionException: com.microsoft.bingads.reporting.CouldNotSubmitReportingDownloadException: java.util.concurrent.ExecutionException: com.microsoft.bingads.reporting.ApiFaultDetail_Exception: Invalid client data. Check the SOAP fault details for more information
at com.microsoft.bingads.internal.ResultFuture.get(ResultFuture.java:96)
at ads.ReportRequests.backgroundCompletion(ReportRequests.java:172)
at ads.ReportRequests.main(ReportRequests.java:90)
Caused by: com.microsoft.bingads.reporting.CouldNotSubmitReportingDownloadException: java.util.concurrent.ExecutionException: com.microsoft.bingads.reporting.ApiFaultDetail_Exception: Invalid client data. Check the SOAP fault details for more information
at com.microsoft.bingads.reporting.ReportingServiceManager$3.handleResponse(ReportingServiceManager.java:216)
at org.apache.cxf.jaxws.JaxwsClientCallback.handleException(JaxwsClientCallback.java:87)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:821)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1638)
at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1145)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:428)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:353)
at java.lang.Thread.run(Unknown Source)
Caused by: java.util.concurrent.ExecutionException: com.microsoft.bingads.reporting.ApiFaultDetail_Exception: Invalid client data. Check the SOAP fault details for more information
at org.apache.cxf.jaxws.JaxwsClientCallback$2.get(JaxwsClientCallback.java:99)
at com.microsoft.bingads.reporting.ReportingServiceManager$3.handleResponse(ReportingServiceManager.java:202)
... 9 more
Caused by: com.microsoft.bingads.reporting.ApiFaultDetail_Exception: Invalid client data. Check the SOAP fault details for more information
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.cxf.interceptor.ClientFaultConverter.processFaultDetail(ClientFaultConverter.java:182)
at org.apache.cxf.interceptor.ClientFaultConverter.handleMessage(ClientFaultConverter.java:82)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:140)
at org.apache.cxf.jaxws.handler.soap.SOAPHandlerInterceptor.handleMessage(SOAPHandlerInterceptor.java:71)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:780)
... 7 more
对于其他报告类型,此错误通常意味着我忘记设置一些必需的参数(例如范围)。在这里我只是不知道。我该如何调试这个问题(例如检查错误消息中提到的这个“SOAP 数据”)?
有没有人有预算摘要报告下载的工作示例?
编辑:下面 Eric Urban 的回答解决了我的问题。每个报告请求类型都有一些需要手动指定并添加到 ReportRequest 对象的列。