Reputation: 637
I am using python requests HTTP POST to send a data to a certain third-party website I do not own. But I can't get it to work because I am getting 414 status code.
url = "http://someurl.com"
headers = {
'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8"
}
params = {'input': "Lorem ipsum... very long string"}
result = requests.post(url, params=params, headers=headers)
print(result.status_code)
How can I get this to work?
Upvotes: 4
Views: 3455
Reputation: 8835
Looking at the docs, it seems that result = requests.post(url, params=params, headers=headers)
should be result = requests.post(url, data=params, headers=headers)
(credit to John La Rooy).
IIRC the params
flag means the params you see tacked onto the end of your url, while data
is the POST data.
Upvotes: 9