Correct way to delete a keyword

386 views
Skip to first unread message

Manish Khettry

unread,
Jan 27, 2010, 3:36:40 PM1/27/10
to AdWords API Forum
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);

James604

unread,
Jan 27, 2010, 4:04:41 PM1/27/10
to AdWords API Forum
If you want to delete a keyword, you should use
AdGroupCriterionOperation.operator = Operator.REMOVE, not just set the
user status on BiddableAdGroupCriterion.


James

AdWords API Advisor

unread,
Jan 28, 2010, 1:48:40 PM1/28/10
to AdWords API Forum
Hi Manish,

James is correct, you'll want to use a REMOVE operation instead. As
for the userStatus, the documentation indicates that DELETED cannot be
used for BAGC:

http://code.google.com/apis/adwords/v2009/docs/reference/AdGroupCriterionService.BiddableAdGroupCriterion.html#userStatus

Best,
- Eric Koleda, AdWords API Team

Rich Johns

unread,
Jan 28, 2010, 2:15:38 PM1/28/10
to adwordsa...@google.com, AdWords API Forum
There may be more doc somewhere, but following the link provided, I
only find this:

"Current user set state of criterion.
During an ADD operation: It may not be set to DELETED. Defaults to
UserStatus.Active if unspecified."

which is ambiguous wrt to SET. Not trying to get pissy here, just fyi.

> --
> You received this message because you are subscribed to the Google Groups "AdWords API Forum" group.
> To post to this group, send email to adwor...@googlegroups.com.
> To unsubscribe from this group, send email to adwords-api...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/adwords-api?hl=en.
>
>

--
rp johns

AdWords API Advisor

unread,
Jan 29, 2010, 11:10:18 AM1/29/10
to AdWords API Forum
Hi Rich,

Thanks for pointing that out, I had missed the "During an ADD
operation:" part, which does muddle the description a bit. I'll work
with the documentation team to have that flushed out.

Best,
- Eric

On Jan 28, 2:15 pm, Rich Johns <ridge.h...@gmail.com> wrote:
> There may be more doc somewhere, but following the link provided, I
> only find this:
>
> "Current user set state of criterion.
> During an ADD operation: It may not be set to DELETED. Defaults to
> UserStatus.Active if unspecified."
>
> which is ambiguous wrt to SET.  Not trying to get pissy here, just fyi.
>
> On Thu, Jan 28, 2010 at 12:48 PM, AdWords API Advisor
>
>
>
>
>
> <adwordsapiadvi...@google.com> wrote:
> > Hi Manish,
>
> > James is correct, you'll want to use a REMOVE operation instead.  As
> > for the userStatus, the documentation indicates that DELETED cannot be
> > used for BAGC:
>

> >  http://code.google.com/apis/adwords/v2009/docs/reference/AdGroupCrite...

Reply all
Reply to author
Forward
0 new messages