How I clear CPC for Keyword in AdWords API (Java/v201609)?

91 views
Skip to first unread message

kan...@gmail.com

unread,
Nov 28, 2016, 9:39:23 AM11/28/16
to AdWords API Forum
I tried and succeeded at create CPC for keyword just that

When I want to clear this CPC without remove keyword, how I can do that?


I tried
Operator.REMOVE at AdGroupCriterionOperation
 result... clear CPC with remove Keyword.

I tried too
Operator.SET at AdGroupCriterionOperation
Keyword keyword = new Keyword();
keyword
.setId(keywordId);

BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion();
biddableAdGroupCriterion
.setAdGroupId(adGroupId);
biddableAdGroupCriterion
.setCriterion(keyword);

BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration();
CpcBid bid = new CpcBid();
bid
.setBid(new Money(null, amount));
biddingStrategyConfiguration
.setBids(new Bids[] {bid});
biddableAdGroupCriterion
.setBiddingStrategyConfiguration(biddingStrategyConfiguration);
 result... update CPC in new amount

and replace bids
biddingStrategyConfiguration.setBids(new Bids[]{});
 result... no change

biddingStrategyConfiguration.setBids(new Bids[]{new CpcBid()});
 result... no change

change bid to null
bid.setBid(null);
 result... NullPointException

change Money.microAmount
new Money(null, null);
 result... NullPointException

new Money(null, 0);
 result... NullPointException

new Money(null, -1);
 result... BiddingErrors.BID_TOO_SMALL


Let me know how to clear keyword cpc from AdGroupCriterion please

Shwetha Vastrad (AdWords API Team)

unread,
Nov 28, 2016, 12:03:22 PM11/28/16
to AdWords API Forum
Hi,

To remove a bid from a BiddingStrategyConfiguration, you need to update its bid field to a Money object with microAmount set to 0. When you use the example provided here to clear the bid this way, you'll encounter NullPointerException as the criterionCpcBid is assigned a value when the CpcBidSource is "CRITERION" and is otherwise null. When the operation to clear the bid is successful, the CpcBidSource is "ADGROUP" so criterionCpcBid will not be assigned a value. You need to modify the example to account for this when the response is processed. 

Let me know if this works. 

Regards,
Shwetha, AdWords API Team.

kan...@gmail.com

unread,
Nov 28, 2016, 8:55:12 PM11/28/16
to AdWords API Forum
Hi, Shwetha.

Yes, my CpcBidSource is 'CRITERION'. well, how i can change CpcBidSource?
In the first place, I want to return CpcBidSource to 'ADGROUP' after add keyword level CPC(It follows that CpcBidSource changed to 'CRITERION')

thank you.
Kanek3

kan...@gmail.com

unread,
Nov 29, 2016, 2:58:47 AM11/29/16
to AdWords API Forum
Sorry,I got wrong idea earlier.

I delete
criterionCpcBid.getBid().getMicroAmount()
from my code.
Then, it works as my wish!

Thank you for your help!
Kanek3 :-)
Reply all
Reply to author
Forward
0 new messages