Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Circumvent Error 414 on HTTP POST using python requests

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?

like image 504
macdelacruz Avatar asked Oct 21 '25 15:10

macdelacruz


1 Answers

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.

like image 164
Snakes and Coffee Avatar answered Oct 24 '25 05:10

Snakes and Coffee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!