0

Here's what I'm doing:

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

And here's my handler method:

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

Where I step through I get this error:

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

Been searching for hours trying to find a solution. Any hints?

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 に答える