The following print
outputs a copy/pastable Curl command which works as expected in my terminal and the server responds with 200:
print (
"curl 'https://some.domain.com/path"
"?param1=1¶m2=2' "
"-X PUT "
"-H 'Host: foo.domain.com' "
"-H 'User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0' "
"-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' "
"-H 'Accept-Language: en-US,en;q=0.5' "
"-H 'Accept-Encoding: gzip, deflate' "
"-H 'Content-Type: application/json; charset=utf-8' "
"-H 'SomeToken: a16e7f17df3f4bdb982dac9593a941ab' "
"-H 'Cookie: "
"cookie1=value1; "
"' "
"-H 'Connection: keep-alive' "
"--data "
'\'{"name":"blubb_234","someId":1234,"someVal":"...",'
'"yoyoyo":"","cool":{"id":7},"price":"125.5","currency":"EUR"}\''
)
The following requests command is as far as I can tell a direct translation of above Curl command. But in this case the server responds with a 500:
res = requests.request("PUT",
("https://some.domain.com/path"
"?param1=1¶m2=2"),
headers={
"Host": "foo.domain.com",
"User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/json; charset=utf-8",
"SomeToken": "a16e7f17df3f4bdb982dac9593a941ab",
"Connection": "keep-alive"
},
data={
"name": "blubb_234",
"someId": 1234,
"someVal": "...",
"yoyoyo": "",
"cool": {"id":7},
"price":"125.5",
"currency":"EUR"
},
cookies={"cookie1":"value1"}
)
Any idea what might be wrong?
> requests.__version__
2.2.1
> sys.version
'2.7.6 (default, Jun 22 2015, 17:58:13) \n[GCC 4.8.2]'