Anash,
I don't know if I was wrong, but I want to clarify the situation:
-with API v200909:
LanguageTargetList languageTargetList = new
LanguageTargetList();
.....
GeoTargetList geoTargetList = new GeoTargetList();
...
TargetList[] targets = new TargetList[]
{ languageTargetList, geoTargetList };
System.Collections.ArrayList campaignTargetOperations
= new System.Collections.ArrayList();
foreach (TargetList target in targets)
{
CampaignTargetOperation ops = new
CampaignTargetOperation();
ops.operatorSpecified = true;
ops.@operator = Operator.SET;
ops.operand = target;
campaignTargetOperations.Add(ops);
}
According to that code, even if how many languages and geo
points, when I add them to TargetList array, I have only 2 operations.
- With the new API:
Since the new API does not support anything than
AdScheduleTargetList, I have to update a lot of criteria but no way to
use SET operator.
int allTargets = ...;
CampaignCriterion[] criteria = new
CampaignCriterion[allTargets];
foreach(...)
{
...
}
List<CampaignCriterionOperation> operations = new
List<CampaignCriterionOperation>();
foreach (CampaignCriterion criterion in criteria)
{
CampaignCriterionOperation operation = new
CampaignCriterionOperation();
operation.@operator = Operator.ADD;
operation.operand = criterion;
operations.Add(operation);
}
For example, if I have 1 language criterion and 300
location criteria, so I'll have 301 operations? I think that was the
reason I got the error EntityCountLimitExceeded.CAMPAIGN_LIMIT but I
don't know how to solve the problem.
The above code was written based on
AddCampaignTargetingCriteria.cs in v201109 package samples.