Reputation: 757
I have a curl command that works and gives me back the JSON. Curl command:
curl -sS -k -L -H "Authorization: bearer <token>" -X GET https://IP:PORT/api/v1/namespaces
I tried with requests
and pycurl
modules which I found in the other posts but no luck.
Can anyone help me with finding the equivalent in python???
Upvotes: 0
Views: 447
Reputation: 6418
We can do this with requests like this:
import requests
header = {'Authorization': 'bearer <token>'}
resp = requests.get("https://IP:PORT/api/v1/namespaces",
headers = header,
verify=False)
print(resp.status_code)
print(resp.text)
-H
switch behaviour is replicated by sending a header-L
switch behaviour is replicated by specifying verify=False
-sS
and -k
are about the behaviour of curl and not relevant here-X GET
is replicated by using requests.get()
Upvotes: 1