Hello!
I am uploading offline conversions using googleads api. My goal is to upload records that can be uploaded and do something with the records that can't be uploaded (ex: OfflineConversionError.EXPIRED_CLICK). I am using a standard template for my 'main' function from v201809 'upload_offline_conversions.py'. Here is what I'm doing:
try:
main(adwords_client, conv_name, gclid, conv_dt, con_vl)
except errors.GoogleAdsServerFault as er:
if er.errors[0]['errorString'] == 'OfflineConversionError.EXPIRED_CLICK':
print('Do something')
Output that I get:
Do something
Error summary: {'faultMessage': '[OfflineConversionError.EXPIRED_CLICK @ operations[0].operand]', 'requestId': '00059ca5009cf2710a37d718110105b0', 'serviceName': 'OfflineConversionFeedService', 'methodName': 'mutate', 'operations': '1', 'responseTime': '318'}
The code still runs, but why am I seeing 'Error summary', which can appear before or after 'Do something' statement? And how can I get rid of it? My initial problem was trying to isolate OfflineConversionError.EXPIRED_CLICK error which I'm trying to do with 'except' statement above.
Another solution in dealing with this might be using 'client.partial_failure = True' in 'main' function. However, then I'm not sure how to 'Do something' with the clicks that fall into OfflineConversionError.EXPIRED_CLICK category, since then I'm getting 'TypeError: 'NoneType' object is not subscriptable' which comes from the
print('Uploaded offline conversion value of "{}" for Google Click ID '
'"{}" to "{}".'.format(new_feed[0]['conversionValue'], new_feed[0]['googleClickId'],
new_feed[0]['conversionName']))
statement inside 'main' function.
The only thing that I can currently do in order to avoid 'Error summary' is to 'client.partial_failure = True' and do the following:
try:
main(adwords_client, conv_name, gclid, conv_dt, con_vl)
except Exception as er:
print(er.__dict__)
print(er.args)
print('Do something')
With output:
{}
("'NoneType' object is not subscriptable",)
Do something
But it doesn't fit my task of doing something with messages with different (possible) error types.
Any help would be greatly appreciated!
Regards,
Iskander