Type 'AdGroupCriterionOperation' is not validly derived from the type definition, 'AdGroupCriterion'

289 views
Skip to first unread message

Johnny

unread,
Jun 24, 2015, 10:17:37 AM6/24/15
to adwor...@googlegroups.com
I'm trying to create an experiment via the API using the ruby client library. Creating the experiment works ok but when I try to add a keyword I get:

/home/johnny/.rvm/gems/ruby-2.1.6/gems/google-ads-common-0.9.8/lib/ads_common/savon_service.rb:113:in `handle_errors': Unknown exception with error: Unmarshalling Error: cvc-elt.4.3: Type 'AdGroupCriterionOperation' is not validly derived from the type definition, 'AdGroupCriterion', of element 'operand'.  (AdsCommon::Errors::ApiException)
from /home/johnny/.rvm/gems/ruby-2.1.6/gems/google-ads-common-0.9.8/lib/ads_common/savon_service.rb:83:in `execute_action'
from /home/johnny/.rvm/gems/ruby-2.1.6/gems/google-adwords-api-0.13.2/lib/adwords_api/v201409/ad_group_criterion_service.rb:25:in `mutate'
from ../adwords_play.rb:52:in `<main>'

Any ideas why? The relevant part of my code follows.

ad_group_criterion_srv = adwords.service(:AdGroupCriterionService, API_VERSION)
ad_group_criterion = {
:xsi_type => 'AdGroupCriterionOperation',
:operand => {
:xsi_type => 'BiddableAdGroupCriterion',
:ad_group_id => 'xxxxxx',
:criterion => {
  :xsi_type => 'Keyword',
  :match_type => 'BROAD',
  :id => 'xxxxxx'
}
}
}
operation = {
  :operator => 'ADD',
  :operand => ad_group_criterion
}

# Update criterion.
response = ad_group_criterion_srv.mutate([operation])

Michael Cloonan (AdWords API Team)

unread,
Jun 24, 2015, 1:07:39 PM6/24/15
to adwor...@googlegroups.com, jon.y...@gmail.com
Hello,

It looks like you are nesting one too many maps deep. You shouldn't need to explicitly set the :xsi_type of the AdGroupCriterionOperation, since there's only one type of operation accepted by the AdGroupCriterionService.

Notice how your :operand in the operation variable also has an :operand specified.

Try this:
ad_group_criterion = {
:xsi_type => 'BiddableAdGroupCriterion',
:ad_group_id => 'xxxxxx',
:criterion => {
  :xsi_type => 'Keyword',
  :match_type => 'BROAD',
  :id => 'xxxxxx'
}
}
operation = {
  :operator => 'ADD',
  :operand => ad_group_criterion
}

Regards,
Mike, AdWords API Team
Reply all
Reply to author
Forward
0 new messages