Announcement Banner
UNSOLVED

AlexandreCo

updated

4 years ago

A

AlexandreCo

1 Message

0

763

May 27th, 2022 01:00

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")