googleads / googleads-python-lib

The Python client library for Google's Ads APIs
Apache License 2.0
685 stars 975 forks source link

Unmarshalling Error: cvc-type.2: The type definition cannot be abstract for element ns0:customFieldValues. #439

Closed ghost closed 7 months ago

ghost commented 5 years ago

Hello, I am trying to update the custom fields of order using this api library. But I am facing following issue when I update customFieldValues in order object

Unmarshalling Error: cvc-type.2: The type definition cannot be abstract for element ns0:customFieldValues.

FYI, this is what I tried to update the order object

... ...
if 'results' in response and len(response['results']):
    # Update each local order object by changing its notes.
    updated_orders = []
    for order in response['results']:
      # Archived orders cannot be updated.
      if not order['isArchived']:
        order['notes'] = 'Spoke to advertiser. All is well.'
        order['customFieldValues'] = [
            {
                'customFieldId': 1234567,
                'value': {
                    'value': 'this is a test value'
                }
            }
        ]
        updated_orders.append(order)

    # Update orders remotely.
    orders = order_service.updateOrders(updated_orders)
... ...

Thank you!

christopherseeley commented 7 months ago

You need to set the xsi type of the field, see this code for an example: https://github.com/googleads/googleads-python-lib/blob/main/examples/ad_manager/v202402/custom_field_service/set_line_item_custom_field_value.py#L84