NetApp OCI REST API and Python

Here's a brief run through of using Python to get data from the NetApp OnCommand Insight REST API. The Python code / command line is below. Change the highlighted stuff as per your environment/requirements:

from http.client import HTTPSConnection
from base64 import b64encode
c = HTTPSConnection("YOURSERVERIP/HOSTNAME/FQDN")
userAndPass = b64encode(b"YOURUSER:YOURPASS").decode("ascii")
headers = {'Authorization':'Basic %s' % userAndPass}
c.request('GET','rest/v1/YOURREQUEST', headers=headers)
res = c.getresponse()
data = res.read()
print(data)

Image: Using Python to get NetApp OnCommand Insight Data over REST API

Credits: https://stackoverflow.com/questions/6999565/python-https-get-with-basic-authentication

Comments