I'm new with cURL and Requests and I have a doubt on how I can transform a cURL petition to a Requests command in Python.
Looking at Apache Stratos documentation Doc Page to perform a login against the server, in cURL you use:
curl -X GET -H "Content-Type: application/json" -k -v -u admin:admin https://localhost:9443/api/session
And it works on the terminal. Now, I want to do the same on my Django website and to transform the curl URL to python code and use the module "requests" I don't know how pass the user and pass info on the petition.
The code that I have now it's:
headers = {'Content-Type':'application/json'}
data = {}
req = requests.post('https://localhost:9443/api/session', headers=headers, params=data)
But I don't know how pass the user and password so I tried this (Requests Python Login Tutorial)
data = {"username":"admin","password":"admin"}
But I get a certificate error from server:
File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 385, in send raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
So, I'm sending correctly the user and password? How I can solve the certificate error?
Thanks and regards
http://localhost:9443/api/session
. Python requests is actually very smooth dealing with SSL, but a valid SSL cert on localhost seems unlikely.