googleads / google-api-ads-ruby

Ad Manager SOAP API Client Libraries for Ruby
297 stars 227 forks source link

AdsCommon::Errors::UnexpectedParametersError: [:type, :value] for custom_field_values on LineItem creation #166

Closed Black-pikaso closed 5 years ago

Black-pikaso commented 5 years ago

Hi. I have a trouble creating a line item with custom_field_values attribute (without custom_field_values it works perfectly) My code example is like this:

line_item_attrs =
{
  :name=>"keytar",
  :order_id=>"2425343678",
  ...,
  ...,
  ...,
  :custom_field_values=>[
    {
      :custom_field_id=>1282985,
      :type=>"CustomFieldValue",
      :value=>{
        :type=>"NumberValue",
        :value=>1
      }
    }
  ]
}

line_item_service.create_line_items([line_item_attrs])

It causes an error: AdsCommon::Errors::UnexpectedParametersError: [:type, :value]

Looks like it is not happy about :type, :value keys of custom_field_values attributes but i was following an example from https://github.com/googleads/google-api-ads-ruby/blob/master/ad_manager_api/examples/v201811/custom_field_service/set_line_item_custom_field_value.rb#L88

gem version = 1.5.0 API version = v201808

Any ideas why it is happening? Any help is appreciated. Thanks

donovanfm commented 5 years ago

Hi. It looks like that's a mistake in our example code. The :type symbol should be :xsi_type. Try changing your example to be like this:

  :custom_field_values => [
    {
      :custom_field_id => 1282985,
      :xsi_type => 'CustomFieldValue',
      :value => {:xsi_type => 'NumberValue', :value => 1}
    }
  ]

Let me know if that fixes the issue for you, and then I'll update our example code. Thanks for catching this!

Black-pikaso commented 5 years ago

Hi. Yeah, replacing type with xsi_type really fixed the issue. Thank you very much for your hint!