Need your expert advise on calling a API.
i was trying to build a script for calling a devices information in Viptela SDWAN. At my home lab script worked as expected, but moment i changed the URL to live office Vmanage hosted on AWS, it gives me error and script was not able to login. however via internet explorer i was able to login into Vmanage GUI.
below is the configuration and error msgs i was getting. any advise will be helpful.
Error's:
Traceback (most recent call last):
File "C:/Users/XXXXXXX/Desktop/New folder (2)/apicallproject.py", line 123, in <module>
my_login()
File "C:/Users/XXXXXXX/Desktop/New folder (2)/apicallproject.py", line 24, in my_login
response = session.post(url=login_url, data=login_credentials, verify=false)
NameError: name 'false' is not defined
Process finished with exit code 1
+++++++++++++++With Verification set to true++++++++++++++++++++++
Traceback (most recent call last):
File "C:/Users/XXXXXXX/Desktop/New folder (2)/apicallproject.py", line 123, in <module>
my_login()
File "C:/Users/XXXXXXXX/Desktop/New folder (2)/apicallproject.py", line 24, in my_login
response = session.post(url=login_url, data=login_credentials, verify=true)
NameError: name 'true' is not defined
Process finished with exit code 1
Below is the python script which is working fine at my home LAB:-
ur = input ("Enter the path to Vmanage :")
name = input("Please enter your user name:")
passw = input("Please enter your password:")
def my_login():
login_url = '%s/j_security_check'%ur
login_credentials = {'j_username': name, 'j_password': passw}
session = requests.session()
response = session.post(url=login_url, data=login_credentials, verify=false)
if b`'<html>'` in response.content:
print('Login Failed')
else:
print('Login Success')
Using
True
orFalse
should work. Perhaps due to different python version.