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:
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)