I moved our AdGroup Negative Keywords to a bulk mutation and now i"m getting this error:
Remote Exception - message:Unmarshalling Error: cvc-elt.4.3: Type 'ns2:Operation' is not validly derived from the type definition, 'BulkMutateJobPolicy', of element 'policy'.
Any notion what is going on here?
This is the rough gist of the code (java). I have a more extensive architecture so it's hard to show.
List<AdGroupCriterionOperation> adGroupOperations = new ArrayList<>();
for (CoiAdGroup coiAdGroup : itemsToCreate) {
List<NegativeKeyword> adGroupKeywords = negativeKeywordService.findByAdGroupId(coiAdGroup.getId());
if (adGroupKeywords != null && !adGroupKeywords.isEmpty()) {
for (NegativeKeyword negativeKeyword : adGroupKeywords) {
if (negativeKeyword.getAdNetworkId() != null) {
continue;
}
AdGroupCriterionOperation operation = addAdGroupNegativeKeywordOperation(negativeKeyword, coiAdGroup);
adGroupOperations.add(operation);
}
}
}
SimpleMutateJob mutateJob = new SimpleMutateJob();
MutateJobServiceInterface batchService = getAdWordsService(mutationRequest.getAccount().getId(), MutateJobServiceInterface.class);
mutateJob = batchService.mutate(operations.toArray(new AdGroupCriterionOperation[adGroupOperations.size()]), new BulkMutateJobPolicy());
private AdGroupCriterionOperation addAdGroupNegativeKeywordOperation(NegativeKeyword negativeKeyword, CoiAdGroup coiAdGroup) {
AdGroupCriterionOperation operation = new AdGroupCriterionOperation();
NegativeAdGroupCriterion adGroupCriterion = new NegativeAdGroupCriterion();
Keyword googlekeyword = new Keyword();
if (negativeKeyword.getAdNetworkId() != null) {
googlekeyword.setId(negativeKeyword.getAdNetworkId());
}
googlekeyword.setText(negativeKeyword.getText());
googlekeyword.setMatchType(convertToGoogleMatchType(negativeKeyword.getMatchType()));
adGroupCriterion.setAdGroupId(coiAdGroup.getAdNetworkId());
adGroupCriterion.setCriterion(googlekeyword);
operation.setOperand(adGroupCriterion);
operation.setOperator(Operator.ADD);
return operation;
}