Hi,

I have followed your location targeting documentation reference, but I am 
facing issue.
https://developers.google.com/google-ads/api/docs/targeting/location-targeting

Remember: I'm using v18.

*Below is my code:*

def set_campaign_locations(client, customer_id, campaign_resource_name, 
countries):
    campaign_criterion_service = 
client.get_service("CampaignCriterionService")
    operations = []

    for country in countries:
        try:
            campaign_criterion_operation = 
client.get_type("CampaignCriterionOperation")
            campaign_criterion = campaign_criterion_operation.create
            campaign_criterion.campaign = campaign_resource_name
            campaign_criterion.location.geo_target_constant = 
client.get_service("GeoTargetConstantService").geo_target_constant_path(country['location_id'])
            operations.append(campaign_criterion_operation)
        except Exception as e:
            print(f"Skipping location ID {country['location_id']}: 
{str(e)}")

    # Send the mutate request.
    try:
        response = campaign_criterion_service.mutate_campaign_criteria(
            customer_id=customer_id, operations=operations
        )
        print(f"Added location criteria: {[res.resource_name for res in 
response.results]}")
    except GoogleAdsException as ex:
        handle_google_ads_exception(ex)

*Below is the error:*

Response

Fault: errors {
  error_code {
    request_error: UNKNOWN
  }
  message: "The error code is not in this version."
  trigger {
    string_value: "OWNED_AND_OPERATED"
  }
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "location"
    }
  }
}

*Also, please provide the solution for targeting keywords (Content) as 
well.*

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
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 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/adwords-api/ea4f6c9f-0e39-40b3-bd6a-a31a921e6d7fn%40googlegroups.com.

Reply via email to