googleads / googleads-python-lib

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

Empty XML nodes incorrectly serialized/deserialized #449

Open christopherseeley opened 4 years ago

christopherseeley commented 4 years ago

Seems like this zeep issue is impacting Ad Manager: https://github.com/mvantellingen/python-zeep/issues/923

Specifically, video line items with an empty requestPlatformTargeting. Reading one of these and sending it unchanged in an updateLineItemsRequest fails with NotNullError.NULL @ targeting.requestPlatformTargeting

aebenw commented 3 years ago

@christopherseeley Is there any update on this? I am experiencing this same issue.

My job is fetching line items and pushing them back up, this property is not changed though yet I'm getting this error.

christopherseeley commented 3 years ago

As a workaround, you can explicitly set an xsi_type for these line items and zeep will correctly serialize it:

line_item['targeting']['requestPlatformTargeting'] = {
            'xsi_type' : 'RequestPlatformTargeting'
        }

For background, an empty <requestPlatformTargeting/> node gets deserialized to None instead of the RequestPlatformTargeting wrapper object. The workaround coerces zeep to serialize it back as: <requestPlatformTargeting></requestPlatformTargeting>.