Special Char in text ad

55 views
Skip to first unread message

jesus....@ogilvy.com

unread,
Nov 16, 2015, 10:42:20 AM11/16/15
to AdWords API Forum
Hi,

I'm using the API with python everythin gis working fine until I try to upload a text ad with the word Mañana in it.

i'm using the Service: 'AdGroupAdService' and the version='v201509'. But I finded imposible to uploaded I kee getting the folloween error:

              UnicodeDecodeError: 'ascii' codec can't decode byte 0xf1 in position 2: ordinal not in range(128)

Can anyone tell me how to solve this problem? 

Thanks

Umesh Dengale

unread,
Nov 16, 2015, 5:48:12 PM11/16/15
to AdWords API Forum
Hello,

This appears to be an issue with how suds handles Unicode in Python 2. That said, it's pretty easy to work around this--all you have to do is send Unicode content in a Unicode string rather than encoding it.

You could change your default encoding as seen in PEP 0263 and use those characters directly.


Thanks,

Umesh, AdWords API Team.

jesus....@ogilvy.com

unread,
Nov 17, 2015, 3:55:42 PM11/17/15
to AdWords API Forum
Hi, I already try  changing the default encoding but still doesn't works, can you tell me the encoding that the mutate function is suposed to read? becausa I have tried with unicode, UTF-8 and iso-8859-15 but with all of that I keep getting the same error.

I don't know what the mutate function does internaly, but based on the error I'm guessing that at some point it tries to decode the string but I can't figure out from what encoding is trying to decode.

thanks

Nadine Sundquist (AdWords API Team)

unread,
Nov 17, 2015, 11:11:09 PM11/17/15
to AdWords API Forum
Hi Jesus,

I'm not a Python expert, so I'm going to ask around to see if one of my colleagues has tried this before. I'll get back to you when I have an answer.

Best,
Nadine, AdWords API Team

Nadine Sundquist (AdWords API Team)

unread,
Nov 18, 2015, 3:26:55 PM11/18/15
to AdWords API Forum
Hi Jesus,

I talked it over with one of our people who knows Python around here. He agrees that this a tough one to solve with Python 2.

His suggestion is, if you're setting the default encoding to utf-8, suds should accept Unicode string containing non-ASCII characters. You could alternatively encode the Unicode string and send it as a byte string. Suds will likely have issues sending the request otherwise, and it doesn't fail gracefully (as you've experienced).

What you're experiencing is very difficult to troubleshoot and can sometimes be environment dependent.

Hope that helps,
Nadine, AdWords API Team
Reply all
Reply to author
Forward
0 new messages