0

这就是我正在做的事情:

Selector selector = new Selector();
selector.fields = new string[] {"CampaignId", "AdGroupId", "Id", "CriteriaType", "Criteria", "CriteriaDestinationUrl", "Clicks", "Impressions", "Cost"};
Predicate predicate = new Predicate();
predicate.field = "Status";
predicate.@operator = PredicateOperator.IN;
predicate.values = new string[] { "ACTIVE", "PAUSED" };
selector.predicates = new Predicate[] { predicate };

ReportDefinition definition = new ReportDefinition();
definition.reportName = "criteria report";
definition.reportType = ReportDefinitionReportType.CRITERIA_PERFORMANCE_REPORT;
definition.downloadFormat = DownloadFormat.XML;
definition.dateRangeType = ReportDefinitionDateRangeType.YESTERDAY;
definition.selector = selector;
definition.includeZeroImpressions = true;

_handler.RunReport(new AdWordsUser(), definition);

这是我的处理程序方法:

public void RunReport(AdWordsUser user, ReportDefinition definition)
{

    if (definition != null)
    {

        string reportContents = string.Empty;

        try
        {
            ReportUtilities utilities = new ReportUtilities(user);
            utilities.ReportVersion = "v201206";
            ClientReport report = utilities.GetClientReport(definition);
            reportContents = report.Contents.ToString();
        }
        catch (Exception ex)
        {
            _errorHandler.AddError(ex);
        }
    }
}   

在我逐步完成的地方出现此错误:

Report contents are invalid. - !!!2|||-1|||[ReportDefinitionError.CUSTOMER_SERVING_TYPE_REPORT_MISMATCH @ selector]???

一直在寻找几个小时试图找到解决方案。有什么提示吗?

4

1 回答 1

0

看来问题确实需要传入customerClientID。

这份文件帮助我描绘了正在发生的事情。

我最终像这样修改了我的代码:

var configOptions = new Dictionary<string,string>();
configOptions.Add("clientCustomerID", customerID.ToString());
_handler.RunReport(new AdWordsUser(configOptions), definition);
于 2012-09-20T22:01:50.087 回答