Python requests.exception.ConnectionError: connection aborted "BadStatusLine"
The problem was with the url. This connection was meant to be established over https and I was using http in the python script. Hence the issue.
Have you actually checked, what gets send over the wire? I suppose you might have to convert your dictionary to a JSON string by yourself, or use the json=
keyword instead of payload=
. See http://docs.python-requests.org/en/latest/user/quickstart/#custom-headers for details. This may do the trick:
import jsonpayload = json.dumps({"mac":new_mac,"token":token})userloginurl = "http://192.168.1.40:9119/uid"r = requests.get(userloginurl, data=payload)print(r.url)
I was getting the same error and spent hours on it. I found that you cannot call the flask server in a client using "Localhost". It has to be "127.0.0.1"
#serverfrom flask import Flaskapp = Flask(__name__)@app.route('/')def hello_world(): return 'Hello World'if __name__ == '__main__': app.run(debug=True)
Now the client causing the error:
#clientimport requestsx = requests.get('http://localhost:5000') # change it to 127.0.0.1print(x.text)