macdelacruz
macdelacruz

Reputation: 637

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?

Upvotes: 4

Views: 3455

Answers (1)

AI Generated Response
AI Generated Response

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

Related Questions