Just send the unicode string to your server and use the header for basic authorization specified in the HP REST API:
login_url = u'https://almalm1250saastrial.saas.hpe.com/qcbin/authentication-point/authenticate' username,password = user,passwd logs = base64.b64encode("{0}:{1}".format(username, password)) header['Authorization'] = "Basic {}".format(logs)
POST using the request module in python is pretty simple:
requests.post(login_url, headers=header)
What is it ... now you are authenticated, and you can continue with the following :-) To verify that you can "GET" on:
login_auth = u'https://almalm1250saastrial.saas.hpe.com/qcbin/rest/is-authenticated
you should get the code 200 -> This means that you are authenticated. Hope this helps you. Have a nice day and let me know if something else is not clear.
ps: send REST msg to python. I am using the query module. It is very easy! You can create a session if you want to send several actions → then work with these sessions → ALM = request.session (), then use ALM.post (whatever) and so on :-)
source share