Hi Gagan,
The PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE error will occur if the
only node you create is the root node. If instead you create the root node
(without a caseValue) and its children all in the same mutate request (as shown
below), then the request should succeed.
// Create Main Parent parentProductPartition and Main Parent
BiddableAdGroupCriterion
ProductPartition parentProductPartition = new ProductPartition();
parentProductPartition.setPartitionType(ProductPartitionType.SUBDIVISION);
parentProductPartition.setId(-1L);
BiddableAdGroupCriterion parentBiddableAdGroupCriterion = new
BiddableAdGroupCriterion();
parentBiddableAdGroupCriterion.setCriterion(parentProductPartition);
parentBiddableAdGroupCriterion.setAdGroupId(Long.parseLong(adGroupID));
parentBiddableAdGroupCriterion.setUserStatus(UserStatus.PAUSED);
parentBiddableAdGroupCriterion.setCriterionUse(CriterionUse.BIDDABLE);
// Create child BiddableAdGroupCriterion and Child ProductPartition on
CUSTOM_ATTRIBUTE_0
ProductPartition childProductPartition = new ProductPartition();
childProductPartition.setPartitionType(ProductPartitionType.UNIT);
childProductPartition.setParentCriterionId(parentProductPartition.getId());
ProductCustomAttribute productDimension1 = new ProductCustomAttribute();
productDimension1.setProductDimensionType("ProductCustomAttribute");
productDimension1.setType(ProductDimensionType.CUSTOM_ATTRIBUTE_0);
productDimension1.setValue("auto-high10");
childProductPartition.setCaseValue(productDimension1);
BiddableAdGroupCriterion childBiddableAdGroupCriterion = new
BiddableAdGroupCriterion();
childBiddableAdGroupCriterion.setCriterion(childProductPartition);
childBiddableAdGroupCriterion.setAdGroupId(Long.parseLong(adGroupID));
childBiddableAdGroupCriterion.setUserStatus(UserStatus.ENABLED);
childBiddableAdGroupCriterion.setCriterionUse(CriterionUse.BIDDABLE);
// Create child NegativeAdGroupCriterion and Child ProductPartition on
CUSTOM_ATTRIBUTE_0
ProductPartition childNegativeProductPartition = new ProductPartition();
childNegativeProductPartition.setPartitionType(ProductPartitionType.UNIT);
childNegativeProductPartition.setParentCriterionId(parentProductPartition.getId());
ProductCustomAttribute productDimension2 = new ProductCustomAttribute();
productDimension2.setProductDimensionType("ProductCustomAttribute");
productDimension2.setType(ProductDimensionType.CUSTOM_ATTRIBUTE_0);
childNegativeProductPartition.setCaseValue(productDimension2);
NegativeAdGroupCriterion childNegativeAdGroupCriterion = new
NegativeAdGroupCriterion();
childNegativeAdGroupCriterion.setCriterion(childNegativeProductPartition);
childNegativeAdGroupCriterion.setAdGroupId(Long.parseLong(adGroupID));
childNegativeAdGroupCriterion.setCriterionUse(CriterionUse.NEGATIVE);
// Set Operation
AdGroupCriterionOperation parentAdGroupCriterionOperation = new
AdGroupCriterionOperation();
parentAdGroupCriterionOperation.setOperand(parentBiddableAdGroupCriterion);
parentAdGroupCriterionOperation.setOperator(Operator.ADD);
AdGroupCriterionOperation child1AdGroupCriterionOperation = new
AdGroupCriterionOperation();
child1AdGroupCriterionOperation.setOperand(childNegativeAdGroupCriterion);
child1AdGroupCriterionOperation.setOperator(Operator.ADD);
AdGroupCriterionOperation child2AdGroupCriterionOperation = new
AdGroupCriterionOperation();
child2AdGroupCriterionOperation.setOperand(childBiddableAdGroupCriterion);
child2AdGroupCriterionOperation.setOperator(Operator.ADD);
AdGroupCriterionServiceInterface adGroupCriterionService =
adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
AdGroupCriterionReturnValue adGroupCriterionReturnValue =
adGroupCriterionService.mutate(
new AdGroupCriterionOperation[]{parentAdGroupCriterionOperation,
child1AdGroupCriterionOperation, child2AdGroupCriterionOperation});
Thanks,
Josh, Google Ads API Team
ref:_00D1U1174p._5001UaSxD8:ref
--
--
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
---
You received this message because you are subscribed to the Google Groups
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/adwords-api/eXl4p000000000000000000000000000000000000000000000Q9OFQU00vSGcPOrORTqrl24X2hbNLA%40sfdc.net.