ProductPartitionTree partitionTree =
ProductPartitionTree.createAdGroupTree(adWordsServices, session, data.getAdGroupId());
ProductPartitionNode partitionNode = partitionTree.getRoot();
ProductOfferId emptyDimensionType = new ProductOfferId();
ProductOfferId dimensionType = ProductDimensions.createOfferId(data.getProductId());
partitionNode
.asSubdivision()
.addChild(emptyDimensionType);
partitionNode
.asSubdivision()
.addChild(dimensionType)
.setBid(partition.getBid());
AdGroupCriterionServiceInterface adGroupCriterionService =
adWordsServices.get(session, AdGroupCriterionServiceInterface.class);
List<AdGroupCriterionOperation> operations = partitionTree.getMutateOperations();
if (operations.isEmpty()) {
log.info("Skipping the mutate call because the original tree and the current tree "
+ "are logically identical.");
} else {
adGroupCriterionService.mutate(
operations.toArray(new AdGroupCriterionOperation[operations.size()]));
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header> <ns1:RequestHeader xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201802" soapenv:mustUnderstand="0"> <ns1:clientCustomerId>295-001-9695</ns1:clientCustomerId> <ns1:developerToken>REDACTED</ns1:developerToken> <ns1:userAgent>backend (AwApi-Java, AdWords-Axis/3.15.0, Common-Java/3.15.0, Axis/1.4, Java/1.8.0_171, maven, ProductPartitionTree)</ns1:userAgent> <ns1:validateOnly>false</ns1:validateOnly> <ns1:partialFailure>false</ns1:partialFailure> </ns1:RequestHeader> </soapenv:Header> <soapenv:Body> <mutate xmlns="https://adwords.google.com/api/adwords/cm/v201802"> <operations> <operator>ADD</operator> <operand xmlns:ns2="https://adwords.google.com/api/adwords/cm/v201802" xsi:type="ns2:BiddableAdGroupCriterion"> <ns2:adGroupId>12345</ns2:adGroupId> <ns2:criterion xsi:type="ns2:ProductPartition"> <ns2:id>-1</ns2:id> <ns2:partitionType>SUBDIVISION</ns2:partitionType> </ns2:criterion> </operand> </operations> <operations> <operator>ADD</operator> <operand xmlns:ns3="https://adwords.google.com/api/adwords/cm/v201802" xsi:type="ns3:BiddableAdGroupCriterion"> <ns3:adGroupId>12345</ns3:adGroupId> <ns3:criterion xsi:type="ns3:ProductPartition"> <ns3:id>-2</ns3:id> <ns3:partitionType>UNIT</ns3:partitionType> <ns3:parentCriterionId>-1</ns3:parentCriterionId> <ns3:caseValue xsi:type="ns3:ProductOfferId"> <ns3:value>testAd2</ns3:value> </ns3:caseValue> </ns3:criterion> <ns3:biddingStrategyConfiguration> <ns3:bids xsi:type="ns3:CpcBid"> <ns3:bid> <ns3:microAmount>30000</ns3:microAmount> </ns3:bid> <ns3:cpcBidSource>CRITERION</ns3:cpcBidSource> </ns3:bids> </ns3:biddingStrategyConfiguration> <ns3:urlCustomParameters> <ns3:doReplace>true</ns3:doReplace> </ns3:urlCustomParameters> </operand> </operations> <operations> <operator>ADD</operator> <operand xmlns:ns4="https://adwords.google.com/api/adwords/cm/v201802" xsi:type="ns4:BiddableAdGroupCriterion"> <ns4:adGroupId>12345</ns4:adGroupId> <ns4:criterion xsi:type="ns4:ProductPartition"> <ns4:id>-3</ns4:id> <ns4:partitionType>UNIT</ns4:partitionType> <ns4:parentCriterionId>-1</ns4:parentCriterionId> <ns4:caseValue xsi:type="ns4:ProductOfferId"/> </ns4:criterion> <ns4:urlCustomParameters> <ns4:doReplace>true</ns4:doReplace> </ns4:urlCustomParameters> </operand> </operations> </mutate> </soapenv:Body></soapenv:Envelope>
<?xml version="1.0" encoding="UTF-8" standalone="no"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <ResponseHeader xmlns="https://adwords.google.com/api/adwords/cm/v201802"> <requestId>00056e3107c457110a371215e70a3b8b</requestId> <serviceName>AdGroupCriterionService</serviceName> <methodName>mutate</methodName> <operations>3</operations> <responseTime>188</responseTime> </ResponseHeader> </soap:Header> <soap:Body> <soap:Fault> <faultcode>soap:Client</faultcode> <faultstring>[RequiredError.REQUIRED @ operations[2].operand.biddingStrategyConfiguration, AdGroupCriterionError.PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE @ operations; trigger:'ProductPartition{id=TempCriterionId{id=1}, bidSimulatorStatus=null, partitionType=SUBDIVISION, parentCriterionId=null, productGroup=null, productGroupObsoleteStatus=null, caseValue=null, decisionPath=[], salesCountry=null, merchantId=null, hasPromotedSuggestion=null}']</faultstring> <detail> <ApiExceptionFault xmlns="https://adwords.google.com/api/adwords/cm/v201802"> <message>[RequiredError.REQUIRED @ operations[2].operand.biddingStrategyConfiguration, AdGroupCriterionError.PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE @ operations; trigger:'ProductPartition{id=TempCriterionId{id=1}, bidSimulatorStatus=null, partitionType=SUBDIVISION, parentCriterionId=null, productGroup=null, productGroupObsoleteStatus=null, caseValue=null, decisionPath=[], salesCountry=null, merchantId=null, hasPromotedSuggestion=null}']</message> <ApplicationException.Type>ApiException</ApplicationException.Type> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="RequiredError"> <fieldPath>operations[2].operand.biddingStrategyConfiguration</fieldPath> <fieldPathElements> <field>operations</field> <index>2</index> </fieldPathElements> <fieldPathElements> <field>operand</field> </fieldPathElements> <fieldPathElements> <field>biddingStrategyConfiguration</field> </fieldPathElements> <trigger/> <errorString>RequiredError.REQUIRED</errorString> <ApiError.Type>RequiredError</ApiError.Type> <reason>REQUIRED</reason> </errors> <errors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="AdGroupCriterionError"> <fieldPath>operations</fieldPath> <fieldPathElements> <field>operations</field> </fieldPathElements> <trigger>ProductPartition{id=TempCriterionId{id=1}, bidSimulatorStatus=null, partitionType=SUBDIVISION, parentCriterionId=null, productGroup=null, productGroupObsoleteStatus=null, caseValue=null, decisionPath=[], salesCountry=null, merchantId=null, hasPromotedSuggestion=null}</trigger> <errorString>AdGroupCriterionError.PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE</errorString> <ApiError.Type>AdGroupCriterionError</ApiError.Type> <reason>PRODUCT_PARTITION_SUBDIVISION_REQUIRES_OTHERS_CASE</reason> </errors> </ApiExceptionFault> </detail> </soap:Fault> </soap:Body></soap:Envelope>
ProductPartitionTree partitionTree = ProductPartitionTree.createAdGroupTree(adWordsServices, session, data.getAdGroupId());
ProductPartitionNode partitionNode = partitionTree .getRoot()
.asSubdivision();
ProductOfferId emptyDimensionType = new ProductOfferId(); ProductOfferId dimensionType = ProductDimensions.createOfferId(data.getProductId());
partitionNode
.addChild(dimensionType) .setBid(data.getBid()) .asBiddableUnit();
partitionNode .addChild(emptyDimensionType) .asExcludedUnit();