converting curl command to a Python3 requests.post (SOAP xml)
I'm trying to get the following command line to work in Python using the 'requests' library:
curl --header "Content-Type: text/xml;charset=UTF-8" --data @test_GetCapabilities.xml http://www.bom.gov.au/waterdata/services?service=SOS
the curl returns the desired response immediately when executed in Anaconda Prompt from the directory containing the test_GetCapabilities.xml file. But the post request does not work when i run the Python script below.
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
r = requests.post(url, data=open(payload), headers=headers)
print(r.content)
The above code times out after about a minute and gives this stack:
runfile('C:/Python/SOAP_curl.py',
wdir='C:/Python') Traceback (most recent
call last):
File "", line 1, in
runfile('C:/Python/SOAP_curl.py', wdir='C:/Python')
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 668, in runfile
execfile(filename, namespace)
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Python/SOAP_curl.py", line 16,
in
r = requests.post(url, data=open(payload), headers=headers)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 58, in request
return session.request(method=method, url=url, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 512, in request
resp = self.send(prep, **send_kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 622, in send
r = adapter.send(request, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestsadapters.py",
line 495, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine('HTTP/1.1 0
Initrn'))
Here is the contents of test_GetCapabilities.xml:
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:sos="http://www.opengis.net/sos/2.0"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ows="http://www.opengis.net/ows/1.1"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:swes="http://www.opengis.net/swes/2.0"
xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
http://www.opengis.net/sos/2.0
http://schemas.opengis.net/sos/2.0/sos.xsd">
<soap12:Header>
<wsa:To>http://www.ogc.org/SOS</wsa:To>
<wsa:Action> http://www.opengis.net/def/serviceOperation/sos/core/2.0/GetCapabilities
</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>0</wsa:MessageID>
</soap12:Header>
<soap12:Body>
<sos:GetCapabilities service="SOS"/>
</soap12:Body>
</soap12:Envelope>
python-3.x curl soap python-requests
add a comment |
I'm trying to get the following command line to work in Python using the 'requests' library:
curl --header "Content-Type: text/xml;charset=UTF-8" --data @test_GetCapabilities.xml http://www.bom.gov.au/waterdata/services?service=SOS
the curl returns the desired response immediately when executed in Anaconda Prompt from the directory containing the test_GetCapabilities.xml file. But the post request does not work when i run the Python script below.
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
r = requests.post(url, data=open(payload), headers=headers)
print(r.content)
The above code times out after about a minute and gives this stack:
runfile('C:/Python/SOAP_curl.py',
wdir='C:/Python') Traceback (most recent
call last):
File "", line 1, in
runfile('C:/Python/SOAP_curl.py', wdir='C:/Python')
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 668, in runfile
execfile(filename, namespace)
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Python/SOAP_curl.py", line 16,
in
r = requests.post(url, data=open(payload), headers=headers)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 58, in request
return session.request(method=method, url=url, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 512, in request
resp = self.send(prep, **send_kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 622, in send
r = adapter.send(request, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestsadapters.py",
line 495, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine('HTTP/1.1 0
Initrn'))
Here is the contents of test_GetCapabilities.xml:
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:sos="http://www.opengis.net/sos/2.0"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ows="http://www.opengis.net/ows/1.1"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:swes="http://www.opengis.net/swes/2.0"
xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
http://www.opengis.net/sos/2.0
http://schemas.opengis.net/sos/2.0/sos.xsd">
<soap12:Header>
<wsa:To>http://www.ogc.org/SOS</wsa:To>
<wsa:Action> http://www.opengis.net/def/serviceOperation/sos/core/2.0/GetCapabilities
</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>0</wsa:MessageID>
</soap12:Header>
<soap12:Body>
<sos:GetCapabilities service="SOS"/>
</soap12:Body>
</soap12:Envelope>
python-3.x curl soap python-requests
I have also attemped the answer from here: stackoverflow.com/questions/40140412/…
– Jordan
Nov 20 '18 at 22:14
1
i got time out both,with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
can you try this? because i saw curl request data which did not containn
– kcorlidy
Nov 21 '18 at 6:51
Thanks @kcordily. worked a charm! here is the working code:import requests url = 'http://www.bom.gov.au/waterdata/services?service=SOS' payload = "test_GetCapabilities.xml" headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'} with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers) print(r.content);
– Jordan
Nov 22 '18 at 22:50
add a comment |
I'm trying to get the following command line to work in Python using the 'requests' library:
curl --header "Content-Type: text/xml;charset=UTF-8" --data @test_GetCapabilities.xml http://www.bom.gov.au/waterdata/services?service=SOS
the curl returns the desired response immediately when executed in Anaconda Prompt from the directory containing the test_GetCapabilities.xml file. But the post request does not work when i run the Python script below.
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
r = requests.post(url, data=open(payload), headers=headers)
print(r.content)
The above code times out after about a minute and gives this stack:
runfile('C:/Python/SOAP_curl.py',
wdir='C:/Python') Traceback (most recent
call last):
File "", line 1, in
runfile('C:/Python/SOAP_curl.py', wdir='C:/Python')
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 668, in runfile
execfile(filename, namespace)
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Python/SOAP_curl.py", line 16,
in
r = requests.post(url, data=open(payload), headers=headers)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 58, in request
return session.request(method=method, url=url, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 512, in request
resp = self.send(prep, **send_kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 622, in send
r = adapter.send(request, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestsadapters.py",
line 495, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine('HTTP/1.1 0
Initrn'))
Here is the contents of test_GetCapabilities.xml:
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:sos="http://www.opengis.net/sos/2.0"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ows="http://www.opengis.net/ows/1.1"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:swes="http://www.opengis.net/swes/2.0"
xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
http://www.opengis.net/sos/2.0
http://schemas.opengis.net/sos/2.0/sos.xsd">
<soap12:Header>
<wsa:To>http://www.ogc.org/SOS</wsa:To>
<wsa:Action> http://www.opengis.net/def/serviceOperation/sos/core/2.0/GetCapabilities
</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>0</wsa:MessageID>
</soap12:Header>
<soap12:Body>
<sos:GetCapabilities service="SOS"/>
</soap12:Body>
</soap12:Envelope>
python-3.x curl soap python-requests
I'm trying to get the following command line to work in Python using the 'requests' library:
curl --header "Content-Type: text/xml;charset=UTF-8" --data @test_GetCapabilities.xml http://www.bom.gov.au/waterdata/services?service=SOS
the curl returns the desired response immediately when executed in Anaconda Prompt from the directory containing the test_GetCapabilities.xml file. But the post request does not work when i run the Python script below.
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
r = requests.post(url, data=open(payload), headers=headers)
print(r.content)
The above code times out after about a minute and gives this stack:
runfile('C:/Python/SOAP_curl.py',
wdir='C:/Python') Traceback (most recent
call last):
File "", line 1, in
runfile('C:/Python/SOAP_curl.py', wdir='C:/Python')
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 668, in runfile
execfile(filename, namespace)
File
"C:ProgramDataAnaconda3libsite-packagesspyder_kernelscustomizespydercustomize.py",
line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Python/SOAP_curl.py", line 16,
in
r = requests.post(url, data=open(payload), headers=headers)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File "C:ProgramDataAnaconda3libsite-packagesrequestsapi.py",
line 58, in request
return session.request(method=method, url=url, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 512, in request
resp = self.send(prep, **send_kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestssessions.py",
line 622, in send
r = adapter.send(request, **kwargs)
File
"C:ProgramDataAnaconda3libsite-packagesrequestsadapters.py",
line 495, in send
raise ConnectionError(err, request=request)
ConnectionError: ('Connection aborted.', BadStatusLine('HTTP/1.1 0
Initrn'))
Here is the contents of test_GetCapabilities.xml:
<soap12:Envelope xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"
xmlns:sos="http://www.opengis.net/sos/2.0"
xmlns:wsa="http://www.w3.org/2005/08/addressing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ows="http://www.opengis.net/ows/1.1"
xmlns:fes="http://www.opengis.net/fes/2.0"
xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:swes="http://www.opengis.net/swes/2.0"
xsi:schemaLocation="http://www.w3.org/2003/05/soap-envelope
http://www.w3.org/2003/05/soap-envelope/soap-envelope.xsd
http://www.opengis.net/sos/2.0
http://schemas.opengis.net/sos/2.0/sos.xsd">
<soap12:Header>
<wsa:To>http://www.ogc.org/SOS</wsa:To>
<wsa:Action> http://www.opengis.net/def/serviceOperation/sos/core/2.0/GetCapabilities
</wsa:Action>
<wsa:ReplyTo>
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>0</wsa:MessageID>
</soap12:Header>
<soap12:Body>
<sos:GetCapabilities service="SOS"/>
</soap12:Body>
</soap12:Envelope>
python-3.x curl soap python-requests
python-3.x curl soap python-requests
asked Nov 20 '18 at 15:57
JordanJordan
334
334
I have also attemped the answer from here: stackoverflow.com/questions/40140412/…
– Jordan
Nov 20 '18 at 22:14
1
i got time out both,with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
can you try this? because i saw curl request data which did not containn
– kcorlidy
Nov 21 '18 at 6:51
Thanks @kcordily. worked a charm! here is the working code:import requests url = 'http://www.bom.gov.au/waterdata/services?service=SOS' payload = "test_GetCapabilities.xml" headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'} with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers) print(r.content);
– Jordan
Nov 22 '18 at 22:50
add a comment |
I have also attemped the answer from here: stackoverflow.com/questions/40140412/…
– Jordan
Nov 20 '18 at 22:14
1
i got time out both,with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
can you try this? because i saw curl request data which did not containn
– kcorlidy
Nov 21 '18 at 6:51
Thanks @kcordily. worked a charm! here is the working code:import requests url = 'http://www.bom.gov.au/waterdata/services?service=SOS' payload = "test_GetCapabilities.xml" headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'} with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers) print(r.content);
– Jordan
Nov 22 '18 at 22:50
I have also attemped the answer from here: stackoverflow.com/questions/40140412/…
– Jordan
Nov 20 '18 at 22:14
I have also attemped the answer from here: stackoverflow.com/questions/40140412/…
– Jordan
Nov 20 '18 at 22:14
1
1
i got time out both,
with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
can you try this? because i saw curl request data which did not contain n
– kcorlidy
Nov 21 '18 at 6:51
i got time out both,
with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
can you try this? because i saw curl request data which did not contain n
– kcorlidy
Nov 21 '18 at 6:51
Thanks @kcordily. worked a charm! here is the working code:
import requests url = 'http://www.bom.gov.au/waterdata/services?service=SOS' payload = "test_GetCapabilities.xml" headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'} with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers) print(r.content);
– Jordan
Nov 22 '18 at 22:50
Thanks @kcordily. worked a charm! here is the working code:
import requests url = 'http://www.bom.gov.au/waterdata/services?service=SOS' payload = "test_GetCapabilities.xml" headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'} with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers) print(r.content);
– Jordan
Nov 22 '18 at 22:50
add a comment |
1 Answer
1
active
oldest
votes
Thanks @kcorlidy.
Here is the corrected working code:
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
with open(payload) as fd:
r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
print(r.content);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396873%2fconverting-curl-command-to-a-python3-requests-post-soap-xml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks @kcorlidy.
Here is the corrected working code:
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
with open(payload) as fd:
r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
print(r.content);
add a comment |
Thanks @kcorlidy.
Here is the corrected working code:
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
with open(payload) as fd:
r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
print(r.content);
add a comment |
Thanks @kcorlidy.
Here is the corrected working code:
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
with open(payload) as fd:
r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
print(r.content);
Thanks @kcorlidy.
Here is the corrected working code:
import requests
url = 'http://www.bom.gov.au/waterdata/services?service=SOS'
payload = "test_GetCapabilities.xml"
headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'}
with open(payload) as fd:
r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
print(r.content);
answered Nov 23 '18 at 4:33
JordanJordan
334
334
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396873%2fconverting-curl-command-to-a-python3-requests-post-soap-xml%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I have also attemped the answer from here: stackoverflow.com/questions/40140412/…
– Jordan
Nov 20 '18 at 22:14
1
i got time out both,
with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers)
can you try this? because i saw curl request data which did not containn
– kcorlidy
Nov 21 '18 at 6:51
Thanks @kcordily. worked a charm! here is the working code:
import requests url = 'http://www.bom.gov.au/waterdata/services?service=SOS' payload = "test_GetCapabilities.xml" headers = {'Content-Type': 'text/xml', 'charset': 'UTF-8'} with open(payload) as fd: r = requests.post(url, data=fd.read().replace("n",""), headers=headers) print(r.content);
– Jordan
Nov 22 '18 at 22:50