Google Ads API: creating an IpBlockInfo instance

420 views Asked by At

I need to modify the blocked IP addresses for a given campaign using the Google Ads API call (version v8). I figured that to add blocked IPs to a given campaign I must create a new campaign criterion, not update an existing one, using the MutateCampaignCriterion endpoint.

My request is

Request: customer_id: "xxxxxxxx"
operations {
  create {
    ip_block {
      ip_address: "xxx.x.x.xx"
    }
    campaign: "customers/xxxxxxx/campaigns/xxxxxxx"
  }
}
validate_only: true

with the proper numbers instead of the x's. The error I get is

Fault: errors {
  error_code {
    criterion_error: FIELD_INCOMPATIBLE_WITH_NEGATIVE_TARGETING
  }
  message: "The field is not allowed to be set when the negative field is set to true, e.g. we don\'t allow bids in negative ad group or campaign criteria."
  location {
    field_path_elements {
      field_name: "operations"
      index: 0
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "ip_block"
    }
  }
}

Even when I set the negative field to false the same occurs. I don't understand why. Any help would be appreciated, thanks!

2

There are 2 answers

0
王冬梅 On

by set campaign_criterion.negative= True

0
Lg102 On

The error in the API is unclear, but the problem is that adding positive criteria is not possible at the campaign level.

Quoting Google Support:

[...], please do note that new campaign will not contain topic criteria by default and only negative criteria are supported at the campaign level. That said, you need to set the negative field to true.

This is reflected in the Google Ads UI: enter image description here