googleads-python-lib icon indicating copy to clipboard operation
googleads-python-lib copied to clipboard

Empty XML nodes incorrectly serialized/deserialized

Open christopherseeley opened this issue 5 years ago • 2 comments

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

christopherseeley avatar Feb 21 '20 20:02 christopherseeley

@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.

aebenw avatar Aug 31 '21 21:08 aebenw

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>.

christopherseeley avatar Oct 12 '21 16:10 christopherseeley