Removing all existing locations

39 views
Skip to first unread message

cos...@gmail.com

unread,
Nov 2, 2018, 9:12:01 AM11/2/18
to AdWords API and Google Ads API Forum
Hello,

I'm adding different locations programmatically to a particular campaign. However this does not edit the current locations but instead simply adds new ones on top.
I'm now trying to first remove all existing locations and then add the new ones.

My code looks like this:

 for criterion_id in criterions_to_remove:
 operations
.append({
 
'operator': 'REMOVE',
 
'operand': {'xsi_type': 'CampaignCriterion', 'campaignId': campaign_id, 'criterion': {'id': criterion_id }}
 
})
 result
= campaign_criterion_service.mutate(operations)

However, I'm now sure how can I query a list of criterions_to_remove for a specific campaign. How can I get all criterion_ids of a campaign, starting with the campaign ID?

The criterions I add to the campaign are: 'xsi_type': 'Proximity'

Luis Xander Talag (AdWords API Team)

unread,
Nov 5, 2018, 1:29:38 AM11/5/18
to AdWords API and Google Ads API Forum
Hi Costantin,

You may refer to the GetCampaignTargetingCriteria code example in Python (available in other languages) in order to query a list of campaign criteria based on PROXIMITY criterion type for a specified campaign. 

Let me know if you have any further concern.

Thanks,
Luis
AdWords API Team
Reply all
Reply to author
Forward
0 new messages