Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80982 > unrolled thread
| Started by | John Gordon <gordon@panix.com> |
|---|---|
| First post | 2014-11-17 20:26 +0000 |
| Last post | 2014-11-20 21:17 +1100 |
| Articles | 4 — 2 participants |
Back to article view | Back to comp.lang.python
Trouble getting full response content from PATCH request John Gordon <gordon@panix.com> - 2014-11-17 20:26 +0000
Re: Trouble getting full response content from PATCH request Cameron Simpson <cs@zip.com.au> - 2014-11-19 14:08 +1100
Re: Trouble getting full response content from PATCH request John Gordon <gordon@panix.com> - 2014-11-19 17:17 +0000
Re: Trouble getting full response content from PATCH request Cameron Simpson <cs@zip.com.au> - 2014-11-20 21:17 +1100
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2014-11-17 20:26 +0000 |
| Subject | Trouble getting full response content from PATCH request |
| Message-ID | <m4dll8$69d$1@reader1.panix.com> |
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 <body> 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 <html> or <body>
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'.
[toc] | [next] | [standalone]
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2014-11-19 14:08 +1100 |
| Message-ID | <mailman.15988.1416366536.18130.python-list@python.org> |
| In reply to | #80982 |
On 17Nov2014 20:26, John Gordon <gordon@panix.com> wrote:
>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 <body> 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 <html> or <body>
>tags.
[...]
You need a "SOAPAction: " HTTP header with SOAP requests. It may be that
simple.
Cheers,
Cameron Simpson <cs@zip.com.au>
Glendower: I can call monsters from the vasty deeps.
Hotspur: Why, so can I, or so can any man. But will they come when you do
call them?
- Henry IV, part 1
[toc] | [prev] | [next] | [standalone]
| From | John Gordon <gordon@panix.com> |
|---|---|
| Date | 2014-11-19 17:17 +0000 |
| Message-ID | <m4ijak$kmn$1@reader1.panix.com> |
| In reply to | #81024 |
In <mailman.15988.1416366536.18130.python-list@python.org> Cameron Simpson <cs@zip.com.au> writes: > >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 <body> 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 <html> or <body> > >tags. > [...] > You need a "SOAPAction: " HTTP header with SOAP requests. It may be that > simple. The API does provide some SOAP calls, but the specific call I'm using is REST. Is there a corresponding header I should use? Thanks. -- 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'.
[toc] | [prev] | [next] | [standalone]
| From | Cameron Simpson <cs@zip.com.au> |
|---|---|
| Date | 2014-11-20 21:17 +1100 |
| Message-ID | <mailman.16012.1416479675.18130.python-list@python.org> |
| In reply to | #81035 |
On 19Nov2014 17:17, John Gordon <gordon@panix.com> wrote: >In <mailman.15988.1416366536.18130.python-list@python.org> Cameron Simpson <cs@zip.com.au> writes: >> >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 <body> 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 <html> or <body> >> >tags. >> [...] > >> You need a "SOAPAction: " HTTP header with SOAP requests. It may be that >> simple. > >The API does provide some SOAP calls, but the specific call I'm using is >REST. Is there a corresponding header I should use? At this point I have no idea; I took things to be SOAP because your SoapUI tool worked. My next suggestion would be to insert a proxy between yourself and the API, specificly so that you can run your working SoapUI test through it. Then you can get a snapshot of headers and requests that work. We've used Paros in the past, but a search for "debugging http proxy" on Google shows several choices. Cheers, Cameron Simpson <cs@zip.com.au> The ten thousand things How long do any persist? Netscape, too, has gone. - Haiku Error Messages http://www.salonmagazine.com/21st/chal/1998/02/10chal2.html
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web