How to change the status of a keyword (criterion)?

21 views
Skip to first unread message

a...@spatially.com

unread,
Oct 24, 2017, 9:56:15 AM10/24/17
to AdWords API Forum
I'm trying to create a function in a Kotlin application (which uses the Java API) that will update the status of the keyword.  By looking over the documentation i've been able to get close, but I'm not clear on what exactly I need to do to set the status.  This is what I have so far:

    fun ChangeKeywordStatus(keywordId: Long, adGroupId: Long) {
        val keyword
= Criterion()
        keyword
.id = keywordId


        val biddableAdGroupCriterion
= BiddableAdGroupCriterion()
        biddableAdGroupCriterion
.adGroupId = adGroupId
        biddableAdGroupCriterion
.criterion = keyword
       
       
//WHAT DO I DO HERE?


       
// Create operations.
        val operation
= AdGroupCriterionOperation()
        operation
.operand = biddableAdGroupCriterion
        operation
.operator = Operator.SET




        val operation
= CampaignOperation()
        operation
.operand = campaign
        operation
.operator = Operator.SET
        val result
= campaignService.mutate(arrayOf(operation))
   
}

I've looked at the Criterion class but there doesn't appear to be any thing that handles status.  What step am I missing to set the status of my keyword?
Message has been deleted

a...@spatially.com

unread,
Oct 24, 2017, 10:31:13 AM10/24/17
to AdWords API Forum
The Code example should look like this sorry:
    fun ChangeKeywordStatus(keywordId: Long, adGroupId: Long) {
        val keyword
= Criterion()
        keyword
.id = keywordId


        val biddableAdGroupCriterion
= BiddableAdGroupCriterion()
        biddableAdGroupCriterion
.adGroupId = adGroupId
        biddableAdGroupCriterion
.criterion = keyword
       
       
//WHAT DO I DO HERE?


       
// Create operations.
        val operation
= AdGroupCriterionOperation()
        operation
.operand = biddableAdGroupCriterion
        operation
.operator = Operator.
SET

        val result
= campaignService.mutate(arrayOf(operation))
   
}


Shwetha Vastrad (AdWords API Team)

unread,
Oct 24, 2017, 11:36:57 AM10/24/17
to AdWords API Forum
Hi, 

You need to set the BiddableAdGroupCriterion.userStatus to PAUSED in the SET operation to pause a criterion. I'm afraid Kotlin is not one of the supported languages. In the Java client library, you need to set the status to PAUSED as shown here. You can set the status in a similar manner in Kotlin. 

Regards,
Shwetha, AdWords API Team.
Reply all
Reply to author
Forward
0 new messages