Python requests gives SSL unknown protocol -
i trying send request api have set on aws machine.
the code use follows:
import requests import json report_dict = { "client_name": "wayne enterprises", "client_id": 123, "report_type": "api_testing", "timestamp_generated": "2015-07-29t11:00:00z", "report_data": {"revenue": 9000.00} } report_json = json.dumps(report_dict) resp = requests.post("https://my-url.com:8080/my-api/reports", data=report_json,verify=false)
doing this, get:
traceback (most recent call last): file "art2_java_test.py", line 124, in <module> main() file "art2_java_test.py", line 9, in main test_post_good_data() file "art2_java_test.py", line 29, in test_post_good_data resp = requests.post("https://my-url.com:8080/my-api/reports", data=report_json,verify=fal se) file "c:\python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\api.py", line 109, in post return request('post', url, data=data, json=json, **kwargs) file "c:\python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\api.py", line 50, in request response = session.request(method=method, url=url, **kwargs) file "c:\python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\sessions .py", line 465, in request resp = self.send(prep, **send_kwargs) file "c:\python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\sessions .py", line 573, in send r = adapter.send(request, **kwargs) file "c:\python27\lib\site-packages\requests-2.7.0-py2.7.egg\requests\adapters .py", line 428, in send raise sslerror(e, request=request) requests.exceptions.sslerror: [ssl: unknown_protocol] unknown protocol (_ssl.c:5 90)
but when send request http instead of https, (usually) works fine. i've found evidence can have proxy servers, not using one. there other potential reasons error? website available on company's local network, if that's relevant.
.... https://my-url.com:8080/my-api/reports
...but when send request http instead of https, (usually) works fine.
my guess trying same port 8080 http , https. but, servers listen on single port either http or https , not both. means if client trying start tls handshake needed https against port plain error message back. client tries interpret error message tls , returns weird error messages, because response not tls @ all.
Comments
Post a Comment