Pregunta

How would I get the operator (Add/Remove/Set) of an AdgroupCriterion?

    MutateJobService mutateJobService = (MutateJobService)user.GetService(AdWordsService.v201309.MutateJobService);
    JobResult jobResult = mutateJobService.getResult(new BulkMutateJobSelector { includeStats = true, jobIds = jobIDs });
    SimpleMutateResult results = (SimpleMutateResult)jobResult.Item;

    if (results.results != null)
    {
        for (int i = 0; i < results.results.Length; i++)
        {
            Operand operand = results.results[i];
            var operandType = operand.Item.GetType();
            if (operandType.BaseType.Name == "AdGroupCriterion")
            {
                AdGroupCriterion adGroupCriterion = (AdGroupCriterion)operand.Item;
                // how to get operator (add/remove/set)?
            }
        }
    }

Here's how I create the operation:

public static AdGroupCriterionOperation GetAdgroupNegativeKeywordOperation(Keyword keyword, long adgroupID, Google.Api.Ads.AdWords.v201309.Operator operat)
{

    NegativeAdGroupCriterion criterion = new NegativeAdGroupCriterion
    {
        adGroupId = adgroupID,
        criterion = keyword
    };
    AdGroupCriterionOperation operation = new AdGroupCriterionOperation
    {
        @operator = operat,
        operand = criterion
    };

    return operation;
}
¿Fue útil?

Solución

For now, the only way around it, as I see, is to store the operations when I create the job, and match it up the index when I'm getting the results.

(comment by @JeremyAube on Google Adwords API: Get criterion info on APIError led me to this conclusion.)

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top