Reputation: 4434
Sorry to ask such entry level question. I need to translate the following cURL
into python language. I tried to use requests
function, which failed. So could anyone give me some hints? Is it right to choose requests? Should I consider urllib?
Thanks!
cURL code:
$ curl -k -u 'key:secret_key' -X POST https://api.picloud.com/file/new/ -d name=your_file_name
My bad attempt:
r = requests.put('https://api.picloud.com/file/new/',auth=(api_key,api_secretkey),data={'name':'your_file_name'})
I got the following errors:
requests.exceptions.SSLError: [Errno 1] _ssl.c:503: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Do I need to encoded my key and secret key first?
Upvotes: 0
Views: 5707
Reputation: 2881
In your curl command, you have used the -k/--insecure
option to disable SSL certificate verification.
If you want to also disable SSL certificate verification, you can add verify=False
to your requests.put call (See SSL Cert Verification).
But this is surely a bad idea from a security point of view. You must verify peer certificate by providing adequate root CA certificates.
Upvotes: 3