I'm trying to simply update keyword bids using v8 of the Google Ads API 
via AdGroupCriterionService in Python. I've copy/pasted most of the code 
for this particular operation directly from several google-provided 
examples and am getting the same error every time:

*TypeError:* Invalid constructor input for MutateAdGroupCriteriaRequest: 
[{'operator': 'SET', 'operand': {'adGroupId': '128454119123', 'criterion': 
{'id': '1410226011123'}, 'status': 'ENABLED', 
'biddingStrategyConfiguration': {'bids': [{'xsi_type': 'CpcBid', 'bid': 
{'microAmount': '1000000'}}]}}}]

This operation was copied directly from Google's documentation,  but is 
still throwing errors that I can't find a way around, and I can't find any 
additional guidance on *properly* formatting these constructor inputs. Can 
someone please tell me where this is going wrong? I've had nothing but 
problems and non-functioning code examples since moving to the Google Ads 
API. Would greatly appreciate a solution. All IDs below are falsified.
------------------------------------------------------------
from googleads import adwords
from google.ads.googleads.client import GoogleAdsClient

AD_GROUP_ID = '128454119123'
CRITERION_ID = '1410226011123'

def main(client, ad_group_id, criterion_id):
  # Initialize appropriate service.
  ad_group_criterion_service = client.get_service(
      'AdGroupCriterionService', version='v8')

  # Construct operations and update bids.

  operations = [{
      'operator': 'SET',
      'operand': {
          #'xsi_type': 'BiddableAdGroupCriterion',
          'adGroupId': ad_group_id,
          'criterion': {
              'id': criterion_id},
              'status': 'ENABLED',
          'biddingStrategyConfiguration': {
              'bids': [
                   {
                       'xsi_type': 'CpcBid',
                       'bid': {
                           'microAmount': '1000000'
                       }
                   }
               ]
           }
       }
  }]
  ad_group_criteria = 
ad_group_criterion_service.mutate_ad_group_criteria(operations)

  # Display results.
  if 'value' in ad_group_criteria:
    for criterion in ad_group_criteria['value']:
      if criterion['criterion']['Criterion.Type'] == 'Keyword':
        print('Ad group criterion with ad group id "%s" and criterion id '
              '"%s" currently has bids:'
              % (criterion['adGroupId'], criterion['criterion']['id']))
        for bid in criterion['biddingStrategyConfiguration']['bids']:
          print('\tType: "%s", value: %s' %
                (bid['Bids.Type'], bid['bid']['microAmount']))
  else:
    print('No ad group criteria were updated.')


if __name__ == '__main__':
  # Initialize client object.
  credentials = {
    "developer_token": "REDACTED",
    "refresh_token": "REDACTED",
    "client_id": "REDACTED",
    "client_secret": "REDACTED",
    "login_customer_id":"REDACTED"}
    
  adwords_client = GoogleAdsClient.load_from_dict(credentials)

  main(adwords_client, AD_GROUP_ID, CRITERION_ID)

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/e02a99e3-f577-40f1-b076-e602e86d5934n%40googlegroups.com.

Reply via email to