Campaign Criterion Service Error

43 views
Skip to first unread message

Zied Chaari

unread,
Mar 4, 2019, 12:29:19 PM3/4/19
to AdWords API and Google Ads API Forum
Hi everyone,

I'm trying add a group of criteria to my campaign, like bellow, but I'm getting an error message saying CANNOT_ADD_CRITERIA_TYPE.

You could find request and response logs attached.

using (CampaignCriterionService campaignCriterionService = (CampaignCriterionService)user.GetService(AdWordsService.v201809.CampaignCriterionService))
            {
                Location california = new Location()
                {
                    id = 21137L
                };
                Location mexico = new Location()
                {
                    id = 2484L
                };
                Gender Male = new Gender()
                {
                    genderType = GenderGenderType.GENDER_MALE
                };
                List<Criterion> criteria = new List<Criterion>()
                {
                    california,
                    mexico,
                    Male
                };
                List<CampaignCriterionOperation> operations = new List<CampaignCriterionOperation>();
                foreach (Criterion criterion in criteria)
                {
                    CampaignCriterionOperation operation = new CampaignCriterionOperation()
                    {
                        operand = new CampaignCriterion()
                        {
                            campaignId = 1723312294,
                            criterion = criterion
                        },
                        @operator = Operator.ADD
                    };
                    operations.Add(operation);
                }
                try
                {
                    CampaignCriterionReturnValue retVal = campaignCriterionService.mutate(operations.ToArray());
                }
                catch (Exception e)
                {
                    throw;
                }
            } 

Many Thanks,
Zied Chaari
 
request.xml
response.xml

googleadsapi...@google.com

unread,
Mar 4, 2019, 4:59:02 PM3/4/19
to AdWords API and Google Ads API Forum
Hello Zied, 

Thank you for sharing the code snippets. They were really helpful. I see that you're targeting Location and Gender criteria and receiving the error. The error CANNOT_ADD_CRITERIA_TYPE indicates that the criteria type cannot be targeted. The Gender criteria cannot be targeted and can only be excluded through the API at the campaign level. You may refer to this Criteria usage table as a reference. 

Please let me know if you have any other questions.

Regards,
Bharani, AdWords API Team

Was your question answered? Please rate your experience with us by taking a short survey.
If not -- reply to this email and tell us what else we can do to help.

Take Survey

Also find us on our blog and discussion group:
http://googleadsdeveloper.blogspot.com/search/label/adwords_api
https://developers.google.com/adwords/api/community/

Reply all
Reply to author
Forward
0 new messages