If you want to delete a keyword, you should use AdGroupCriterionOperation.operator = Operator.REMOVE, not just set the user status on BiddableAdGroupCriterion.
James On Jan 27, 12:36 pm, Manish Khettry <[email protected]> wrote: > I was trying to delete a keyword by setting its UserStatus to deleted and > then calling the "SET" operation but this is throwing an > "AdGroupCriterionError.INVALID_USER_STATUS @ > operations[0].operand.userStatus]" exception. If however I set the operation > to REMOVE, the keyword is deleted. I just wanted to confirm that this is the > correct way to delete keywords. > > Thanks, > Manish > > Here is my code fragment, which fails. If I switch the Operation from SET to > REMOVE, it seems to nuke the keyword. > > AdGroupCriterionError.INVALID_USER_STATUS @ > operations[0].operand.userStatus] > > Keyword kw = new Keyword(); > kw.setId(gCriteriaKey); > kw.setMatchType(mt); > kw.setText(text); > > AdGroupCriterionOperation[] ops = new AdGroupCriterionOperation[1]; > AdGroupCriterionOperation op = ops[0] = new > AdGroupCriterionOperation(); > op.setOperator(Operator.SET); > > BiddableAdGroupCriterion bagc = new BiddableAdGroupCriterion(); > op.setOperand(bagc); > > bagc.setAdGroupId(gAdGroupKey); > bagc.setCriterion(kw); > bagc.setUserStatus(UserStatus.DELETED); > keywordService.mutate(ops); -- You received this message because you are subscribed to the Google Groups "AdWords 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.
