Not able to remove ip address from campaign using campaignCriteria:mutate

245 views
Skip to first unread message

Abhishek Bhasker

unread,
Jan 10, 2023, 5:48:52 PM1/10/23
to Google Ads API and AdWords API Forum
Hi,

I am able to:

1. Query the current excluded/blocked IP address for the particular campaign with

POST https://googleads.googleapis.com/v12/customers/{customer_id}/googleAds:searchStream
{
   "customerId" : "{customer_id}",
   "query" : " SELECT campaign_criterion.ip_block.ip_address FROM campaign_criterion "
}

2. Able to add exclude/block an IP address to campaign using campaignCriteria:mutate

POST https://googleads.googleapis.com/v12/customers/3930653162/campaignCriteria:mutate
{
   "operations" : [
      {
         "create" : {
            "ipBlock" : {
               "ip_address" : "192.168.23.11"
            },
            "resourceName" : "customers/{customer_id}/campaignCriteria/{campaign_id}~27",
            "negative" : "True"
         }
      }
   ],
   "customerId" : "{customer_id}"
}

But with the same campaignCriteria mutate remove operation is not working.
If I change create operation to remove in this same request, I get this error:
Invalid value at 'operations[1]' (remove), Starting an object on a scalar field

I am using google-ads-perl client lib for these requests.

Is it possible to remove excluded/blocked IP addresses from the campaign using this?
Please let me know if any other information is needed for this question.



Google Ads API Forum Advisor

unread,
Jan 11, 2023, 2:22:25 AM1/11/23
to abhin...@gmail.com, adwor...@googlegroups.com

Hi Abhishek, 

Thanks for reaching out to the Google Ads API Forum. I hope you are doing well today.

With regard to your concern, In order to block IP addresses, you may use CampaignCriterionOperation. You may refer to the Perl code sample in this link. You may also use SET operator (for the mutate operation) to update existing excluded IP addresses (Which will remove existing IP addresses and set the new IP address to exclude provided by SET operator).

See sample curl reference in campaignCriteria mutate remove operation:

curl -f --request POST "https://googleads.googleapis.com/v12/customers/{customerID}/campaignCriteria:mutate" \
--header "Content-Type: application/json" \
--header "developer-token: ${DEVELOPER_TOKEN}" \
--header "login-customer-id: ${MANAGER_CUSTOMER_ID}" \
--header "Authorization: Bearer ${OAUTH2_ACCESS_TOKEN}" \
--data "{
   "operations" : [
      {
        "remove" : "customers/{customerID}/campaignCriteria/{campaignID}~{criterionID}"
      }
   ] 
}"

Please let me know if you have further concerns. Have a great day.

Regards,

Google Logo
Marjorie
Google Ads API Team
 


ref:_00D1U1174p._5004Q2hx0Bk:ref

Abhishek Bhasker

unread,
Jan 11, 2023, 9:18:40 AM1/11/23
to Google Ads API and AdWords API Forum
Thanks, Marjorie, for your quick and prompt response.

Now create/remove IP works with this request data:

POST https://googleads.googleapis.com/v12/customers/{campaignID}/campaignCriteria:mutate
{
    "customerId": "3930653162",
    "operations": [
        {
            "remove": "customers/{customerID}/campaignCriteria/{campaignID}~{IP_RESOURCE_ID}"
        },
        {
            "create": {
                "ipBlock": {
                    "ip_address": "192.168.1.1"
                },
                "resourceName": "customers/{customerID}/campaignCriteria/{campaignID}~{IP_BLOCK_criterionID}",
                "negative": "True"
            }
        }
    ]

}

> You may also use SET operator (for the mutate operation) to update existing excluded IP addresses (Which will remove existing IP addresses and set the new IP address to exclude provided by SET operator).
But any other code example(Perl)/online help topic for this one (SET operator), where I want to overwrite the existing IP? OR even a simple curl request could help.

Please let me know if any other information is needed for this question. Have a great day.

Google Ads API Forum Advisor

unread,
Jan 11, 2023, 2:08:49 PM1/11/23
to abhin...@gmail.com, adwor...@googlegroups.com
Hello,

Please refer to the update curl example, here. The update method is similar to the create method, except a resource name and update mask should be included. 

There isn't a Perl example for updating campaign criterion, but you can refer to the ad group criterion update example that is similar. 

Regards,

Google Logo
Matt
Google Ads API Team
 


ref:_00D1U1174p._5004Q2hx0Bk:ref

Abhishek Bhasker

unread,
Feb 11, 2023, 11:53:30 AM2/11/23
to Google Ads API and AdWords API Forum
Created this Github Repo issue: https://github.com/googleads/google-ads-perl/issues/97

Google Ads API Forum Advisor

unread,
Feb 13, 2023, 1:22:43 AM2/13/23
to abhin...@gmail.com, adwor...@googlegroups.com
Hi Abhishek ,

Thank you for sending updates.

I see that you already submitted this to the Client library Perl using Github's issue tracker. With this, you may please wait for the further solution by the client library owner. 

On the other hand, if you have further questions regarding what my colleague Matt suggested to you, then let us know so that we can still further support you.

Best regards,
Google Logo
Jinky
Google Ads API Team
 


ref:_00D1U1174p._5004Q2hx0Bk:ref
Reply all
Reply to author
Forward
0 new messages