How to send utf-8 content in a urllib2 request?
I'm struggling with the following question for the past half a day and although I've found some info about similar problems, nothing really hits the spot. I'm trying to send a PUT request using urllib2 with data that contains some Unicode characters: body = u'{ "bbb" : "asdf\xd7\xa9\xd7\x93\xd7\x92"}' conn = urllib2.Request(request_url, body, headers) conn.get_method = lambda: 'PUT' response = urllib2.urlopen(conn) I've tried to use body = body.encode('utf-8') and other variations, but whatever I do I get the following error: UnicodeEncodeError at ... 'ascii' codec can't decode byte 0xc3 in