Google ADS API - set devices for a campaign bug?

71 views
Skip to first unread message

Jakub Samsel

unread,
Jun 26, 2019, 6:13:19 AM6/26/19
to AdWords API and Google Ads API Forum
Hi,
I'm using your google ads library for python
When I'm trying to set device for a campaign I'm receiving an error from Google ADS API
        operations = []

        if data['desktop']:
            campaign_criterion_operation = self.client.get_type('CampaignCriterionOperation', version='v1')
            campaign_criterion = campaign_criterion_operation.create
            campaign_criterion.campaign.value = campaign_resource_name
            campaign_criterion.device.type = self.client.get_type('DeviceEnum').DESKTOP
            operations.append(campaign_criterion_operation)
            
        if operations:
            campaign_criterion_service = self.client.get_service('CampaignCriterionService', version='v1)
            campaign_criterion_response = campaign_criterion_service.mutate_campaign_criteria(
                self.customer_id, operations)

Error:

GoogleAdsException at <app_url>
(<_Rendezvous of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "{"created":"@1561531088.389712000","description":"Error received from peer ipv4:216.58.215.106:443","file":"src/core/lib/surface/call.cc","file_line":1046,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
>, <_Rendezvous of RPC that terminated with:
status = StatusCode.INVALID_ARGUMENT
details = "Request contains an invalid argument."
debug_error_string = "{"created":"@1561531088.389712000","description":"Error received from peer ipv4:216.58.215.106:443","file":"src/core/lib/surface/call.cc","file_line":1046,"grpc_message":"Request contains an invalid argument.","grpc_status":3}"
>, errors {
  error_code {
    campaign_criterion_error: OPERATOR_NOT_SUPPORTED_FOR_CRITERION_TYPE
  }
  message: "This operator cannot be applied to a criterion of this type."
  trigger {
    string_value: ""
  }
  location {
    field_path_elements {
      field_name: "operations"
      index {
      }
    }
    field_path_elements {
      field_name: "create"
    }
    field_path_elements {
      field_name: "device"
    }
  }
}

Is there something that I forgot to add to code? Or should I do in another way to change device settings for the campaign?

I noticed that I have a created campaign criteria for devices to selected campaign but I cant update or remove these criteria

Google Ads API Forum Advisor Prod

unread,
Jun 30, 2019, 2:11:12 PM6/30/19
to kubas...@gmail.com, adwor...@googlegroups.com
Hi,

A device criteria for each device implicitly exists in each campaign, so you won't be able to ADD or REMOVE those criteria. However, you can use bid modifiers to opt out of a specific device or set the bid modifier for a specific device. For example, if you want to exclude tablets, you can issue a campaign_criterion SET operation with bid_modifier 0. You can use the example below as a template, although you'll want to replace the highlighted portions with your customer ID and campaign ID. The value of 30002 corresponds to the TABLET enum value.

{
  customer_id: "...",
  validate_only: "false",
  operations:
  [
    {
      update_mask: "bid_modifier",
      update:
      {
        resource_name: "customers/.../campaignCriteria/...~30002",
        bid_modifier: 0.0
      }
    }
  ]
}


Thanks,
Josh, Google Ads API Team
 

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