Unsolved
1 Message
0
691
Using OMIVV 5.4 API with Python/PowerShell
Hello,
I'm trying to login to a OMIVV 5.4 API using Python but for some unknown reason I'm not being able to get it done.
The code I'm using is the following one but it is not working for me.
My end goal is to be able to do this also from Powershell but for now I'm just trying to get this started using Python.
Is anyone able to login to a OMNI 5.4 API?
Thank you
Alexandre
=====
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
def login_with_OMIVV (omivvIP,username,domain, password):
baseurl ="https://" + omivvIP + "/Spectre/api/rest/v1/Services/AuthenticationService/login"
postBodyData={"apiUserCredential" : {"username":username,"domain" : domain,"password" : password}}
jsonReponse = requests.post(baseurl, json=postBodyData, verify=False)
if(jsonReponse.status_code == 200):
bearerToken = jsonReponse['accessToken']
return bearerToken
else:
print("Login failed")
login_with_OMIVV("yyyyyy","admin","","xxxxxxxxx")
adila_abdul_karim
1 Message
0
June 7th, 2022 00:00
Hello,
The issue with the code snippet shared is that it is not able to parse the response to get the access token. I've added a line of code in the snippet below and verified it to be working. Please give this snippet a go.
Thanks,
Adila