Error when updating status on existing ad

179 views
Skip to first unread message

Mikkel Mortensen

unread,
Oct 25, 2016, 12:22:47 PM10/25/16
to AdWords API Forum
Hi

I would like to DISABLE all my ads. My code is very simple:

var selector = new Selector
{
    fields = new string[] { 
        Google.Api.Ads.AdWords.v201607.AdGroupAd.Fields.AdGroupId, 
        Google.Api.Ads.AdWords.v201607.AdGroupAd.Fields.Labels, 
        Google.Api.Ads.AdWords.v201607.AdGroupAd.Fields.Status 
    }
};

var page = adGroupAdService.get(selector);
foreach (var adGroupAd in page.entries.ToList())
{
    var operation = new AdGroupAdOperation
    {
        @operator = Operator.SET,
        operand = adGroupAd
    };

    adGroupAd.status = AdGroupAdStatus.PAUSED;
    adGroupAdService.mutate(new AdGroupAdOperation[] { operation })   
}

I get the exception:
This operator cannot be used with a subclass of Ad.. (Error: AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR, FieldPath: operations[0].operand.ad, Trigger: )

Any help would be highly appreciated.

Kind regards
Mikkel

Shwetha Vastrad (AdWords API Team)

unread,
Oct 25, 2016, 2:24:29 PM10/25/16
to AdWords API Forum
Hi Mikkel,

Could you retry the request by creating new AdGroupAd objects rather than changing the status of the ad objects returned in the response? If you include attributes other than the status in the AdGroupAdOperation, you'll encounter AdError.CANNOT_USE_AD_SUBCLASS_FOR_OPERATOR. Have you tried using the examples provided in the client libraries? It this doesn't solve the issue, please provide the complete SOAP request and response logs so I can further investigate. Please use Reply privately to author when responding.

Thanks,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages