I'm doing a script that makes me a POST
method. I follow the library documentation requests
. I have to make a login; when I use the method GET
no error arises. It consists of several tags with enable ( value=1
) and disable ( value=0
), and at the end of the form has a tag apply changes . Anyway, I have this:
import requests
from requests.auth import HTTPBasicAuth
import json
x = {
"MbssIndexChanged":1,
"GuestkEnable":1,
"GuestServiceSetIdentifier":"guest",
"commitwlanGuestNetwork":1
}
headers = {'User-Agent': 'Mozilla/5.0'}
session = requests.Session()
r = session.post(url, auth=HTTPBasicAuth('user','pass'), data=json.dumps(x))
And I get this error.
Traceback (most recent call last):
File "/home/ubuntu/workspace/post.py", line 23, in <module>
r = session.post(url, auth=HTTPBasicAuth(user,pass), data=json.dumps(data))
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 497, in post
return self.request('POST', url, data=data, **kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 455, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 558, in
send
raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host=url, port=8080): Max retries exceeded with url: /url (Caused by <class 'socket.error'>: [Errno 104] Connection reset by peer)'
I've tried with the retries=False
, with verify=False
and without the session
, but without result.