public void Run(AdWordsUser user, long adGroupId, long keywordId) { // Get the AdGroupCriterionService. AdGroupCriterionService adGroupCriterionService = (AdGroupCriterionService) user.GetService(AdWordsService.v201302.AdGroupCriterionService); // Since we are not updating any keyword-specific fields, it is enough to // create a criterion object. Criterion criterion = new Criterion(); criterion.id = keywordId; // Create ad group criterion. BiddableAdGroupCriterion biddableAdGroupCriterion = new BiddableAdGroupCriterion(); biddableAdGroupCriterion.adGroupId = adGroupId; biddableAdGroupCriterion.criterion = criterion; // Create the bids. BiddingStrategyConfiguration biddingConfig = new BiddingStrategyConfiguration(); CpcBid cpcBid = new CpcBid(); cpcBid.bid = new Money(); cpcBid.bid.microAmount = 1000000; biddableAdGroupCriterion.biddingStrategyConfiguration = biddingConfig; // Create the operation. AdGroupCriterionOperation operation = new AdGroupCriterionOperation(); operation.@operator = Operator.SET; operation.operand = biddableAdGroupCriterion; try { // Update the keyword. AdGroupCriterionReturnValue retVal = adGroupCriterionService.mutate(new AdGroupCriterionOperation[] {operation}); // Display the results. if (retVal != null && retVal.value != null && retVal.value.Length > 0) { AdGroupCriterion adGroupCriterion = retVal.value[0]; long bidAmount = 0; foreach (Bids bids in (adGroupCriterion as BiddableAdGroupCriterion). biddingStrategyConfiguration.bids) { if (bids is CpcBid) { bidAmount = (bids as CpcBid).bid.microAmount; /*original bid always comes back; never changes*/ break; } } Console.WriteLine("Keyword with ad group id = '{0}', id = '{1}' was updated with " + "bid amount = '{2}' micros.", adGroupCriterion.adGroupId, adGroupCriterion.criterion.id, bidAmount); } else { Console.WriteLine("No keyword was updated."); } } catch (Exception ex) { throw new System.ApplicationException("Failed to update keyword.", ex); } }
Actually, I’ve solved this problem. Your sample code was missing a couple of lines. I went ahead and took the liberty of publishing my solution for other folks who have tripped over the same issue…
https://code.google.com/p/google-api-adwords-dotnet/issues/detail?id=110
biddingConfig.bids = new Bids[] { cpcBid };