I tried to PUT the exact XML above (with an acctual username inserted), but with the UTF-8 encoding parameter, and am still getting a 500. Not sure if this will help, but here is the actual Python code that I'm using: import urllib2
import datetime
from xml.dom import minidom
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
top_level_url = "https://api.constantcontact.com/ws/customers/{my-username}/"
password_mgr.add_password(None, top_level_url, 'USER_NAME_STRING', 'PASSWORD')
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
request_string = 'https://api.constantcontact.com/ws/customers/{my-username}/contacts/%s' % constant_contact_id
response = self.opener.open(request_string)
xml_string = response.read()
dom = minidom.parseString(xml_string)
dom.getElementsByTagName('CustomField1')[0].childNodes[0].nodeValue = "Some test value"
dom.getElementsByTagName('CustomField15')[0].childNodes[0].nodeValue = "Some other test value"
update_request = urllib2.Request(request_string, data=dom.toxml(encoding="UTF-8"))
update_request.add_header('Content-Type', 'application/atom+xml')
update_request.get_method = lambda: 'PUT'
print('Putting to: %s' % update_request.get_full_url())
print("Data: %s" % update_request.get_data())
update_response = self.opener.open(update_request)
... View more