Hello Sonic,
That looks correct, so you are using the right version of suds-jurko at least.
On my workstation, I created a campaign with the name that you're having issues parsing and ran the get_campaigns.py example. I ran (sort of) without issues:
INFO:oauth2client.client:Refreshing access_token
DEBUG:suds.transport.http:opening (https://adwords.google.com/api/adwords/cm/v201509/CampaignService?wsdl)
DEBUG:suds.transport.http:sending:
URL: https://adwords.google.com/api/adwords/cm/v201509/CampaignService
HEADERS: {'Soapaction': '""', 'SOAPAction': '""', 'Content-Type': 'text/xml; charset=utf-8', 'Content-type': 'text/xml; charset=utf-8', 'Authorization': u'REDACTED'}
MESSAGE:
<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201509" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="https://adwords.google.com/api/adwords/cm/v201509" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header><tns:RequestHeader><tns:clientCustomerId>REDACTED</tns:clientCustomerId><tns:developerToken>REDACTED</tns:developerToken><tns:userAgent>REDACTED</tns:userAgent><tns:validateOnly>false</tns:validateOnly><tns:partialFailure>false</tns:partialFailure></tns:RequestHeader></SOAP-ENV:Header><ns0:Body><ns1:get><ns1:serviceSelector><ns1:fields>Id</ns1:fields><ns1:fields>Name</ns1:fields><ns1:fields>Status</ns1:fields><ns1:paging><ns1:startIndex>0</ns1:startIndex><ns1:numberResults>100</ns1:numberResults></ns1:paging></ns1:serviceSelector></ns1:get></ns0:Body></SOAP-ENV:Envelope>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/logging/__init__.py", line 859, in emit
msg = self.format(record)
File "/usr/local/lib/python2.7/logging/__init__.py", line 732, in format
return fmt.format(record)
File "/usr/local/lib/python2.7/logging/__init__.py", line 471, in format
record.message = record.getMessage()
File "/usr/local/lib/python2.7/logging/__init__.py", line 335, in getMessage
msg = msg % self.args
File "/usr/local/lib/python2.7/dist-packages/suds/__init__.py", line 168, in <lambda>
__str__ = lambda x: unicode(x).encode('utf-8')
File "/usr/local/lib/python2.7/dist-packages/suds/transport/__init__.py", line 96, in __unicode__
%s""" % (self.code, self.headers, self.message)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 577: ordinal not in range(128)
Logged from file http.py, line 89
Campaign with id '374649914', name '15-abc-1-mmep-中国-IOS', and status 'ENABLED' was found.
The error you're seeing there is a known issue that the suds logger has with unicode characters, but it doesn't prevent the sample from completing. As you can see, the Campaign's name can be retrieved and printed without issues. This definitely seems like an issue specific to the environment the code is run on. I went a step further and ran this on a separate VM instance, and was able to reproduce it in that case.
The workstation has its default character encoding set to utf-8 and the VM has it set to ANSIX3.4-1968, which is probably related. I think suds might have some flaky behavior here depending on the environment used. In the meantime, you can avoid this error by encoding the output of string fields such as:
# Display results.
if 'entries' in page:
for campaign in page['entries']:
print ('Campaign with id \'%s\', name \'%s\', and status \'%s\' was '
'found.' % (campaign['id'], campaign['name'].encode('utf-8'),
campaign['status'].encode('utf-8')))
I'll continue investigating this, as a better fix may need to come upstream from the suds library.
Regards,
Mark