Hi Google Team,

        I'm trying to *add user_interest criterion on ad group level*, but 
i *cannot mutate it*.
I keep getting following error - "*TypeError: Parameter to MergeFrom() must 
be instance of same class: expected 
google.ads.googleads.v5.services.AdGroupCriterionOperation got 
google.ads.googleads.v5.resources.AdGroupCriterion*"

 I have attached my code and request 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/070e8d2e-d3e4-49d0-b5a7-25899def034fn%40googlegroups.com.
[2021-03-27 11:45:45,761 - INFO] Request made: ClientCustomerId: 6948339166, Host: googleads.googleapis.com:443, Method: /google.ads.googleads.v5.services.AdGroupService/MutateAdGroups, RequestId: xBqDQ6a_BY37kYFyXYt6ow, IsFault: False, FaultMessage: None 


def adgroup_criterion_operation(customer_id, kwargs):
    client = connect_ads_api()
    adgroup_criterion_service = client.get_service("AdGroupCriterionService", version="v5")        
    criterion_operations_list = []
    for interest_id in kwargs['affinity_list']:
        adgroup_criterion_operation = client.get_type("AdGroupCriterionOperation", version="v5")
        ad_group_operation = adgroup_criterion_operation.create        
        ad_group_operation.user_interest.user_interest_category = f'customer/{customer_id}/userInterests/{interest_id}'
        criterion_operations_list.append(ad_group_operation)
    try:
        response = adgroup_criterion_service.mutate_ad_group_criteria(
            customer_id, criterion_operations_list
        )
    except GoogleAdsException as ex:
        print(
            f'Request with ID "{ex.request_id}" failed with status '
            f'"{ex.error.code().name}" and includes the following errors:'
        )
        for error in ex.failure.errors:
            print(f'\tError with message "{error.message}".')
            if error.location:
                for field_path_element in error.location.field_path_elements:
                    print(f"\t\tOn field: {field_path_element.field_name}")
        return None
    return True


Reply via email to