Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Trouble getting full response content from PATCH request Date: Mon, 17 Nov 2014 20:26:16 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 45 Message-ID: NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1416255976 6445 166.84.1.1 (17 Nov 2014 20:26:16 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Mon, 17 Nov 2014 20:26:16 +0000 (UTC) Keywords: patch, body, content User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:80982 I'm working with a third-party API and I'm seeing some behavior that I can't explain. The API uses the HTTP PATCH operation to set user passwords, and in case of unacceptable passwords, the response is supposed to be an HTML document containing a diagnostic message in the tag. When I submit my test data via a functional testing tool (SoapUI), it behaves as expected. However, when I submit test data from Python code, the response content consists only of the diagnostic message, with no enclosing or tags. Does anyone have an idea why this might be happening? Here's a sample of the code I'm using: import requests # API credentials -- username and password auth = ('foo', 'bar') # xml for setting password with open('set_password.xml') as f: raw_xml = f.read() # fill in the requested password body = raw_xml.format(password='hello') headers = {'Content-type': 'text/xml'} url = 'https://some.server.com/api/call/' response = requests.patch(url, data=body, auth=auth, verify=False, headers=headers) print 'HTTP status code: %s' % response.status_code print 'response content:' print response.content -- John Gordon Imagine what it must be like for a real medical doctor to gordon@panix.com watch 'House', or a real serial killer to watch 'Dexter'.