cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1159
Views
5
Helpful
3
Replies

Using Python to interact with the Cisco SD-WAN REST API (Learning Lab)

eggy!
Level 1
Level 1

I'm stuck on "Step 1: Login and authenticate with Python code".

There's no command example to execute the #sdwan.py login.

Are we supposed to add the arguments for the 'url', 'username', 'password' in the command line.

Or, are the environment variables supposed to be changed? :

export SDWAN_IP=10.10.30.190

export SDWAN_USERNAME=admin

export SDWAN_PASSWORD=admin

 

example, change; SDWAN_IP="https://sandboxsdwan.cisco.com:8443/j_security_check"

Thanks (in advance).

(Or, should i give up DevNet and play more guitar?)

3 Replies 3

eggy!
Level 1
Level 1

Hi eggy!, this is eggy!

In reply to my own question:

You do in fact have to define those environment variables.

below are some 'prints' to show how they look as the login is stepped thru:

(venv) unknown28f07628886e:Getting-started-with-Cisco-SD-WAN-REST-APIs eggy$ ./sdwan.py template_list
base_url_str
https://sandboxsdwan.cisco.com:8443/
login_data
{'j_username': 'devnetuser', 'j_password': 'Cisco123!'}
login_url
https://sandboxsdwan.cisco.com:8443/j_security_check
url
https://sandboxsdwan.cisco.com:8443/j_security_check
login_response
<Response [200]>
Login Failed
(venv) unknown28f07628886e:Getting-started-with-Cisco-SD-WAN-REST-APIs eggy$ 

(Note: the Cisco code has an extra '/' after the port# that you have to remove).

However, I'm still getting a 'Login Failed', even thought the 'response' is giving a <Response [200]>
Isn't [200] a successful login?

 

Hi eggy

 

You have to change the variables in the script to point to the sandbox or setup local variables. 

export SDWAN_IP=https://sandboxsdwan.cisco.com:8443
export SDWAN_USERNAME=devnetuser
export SDWAN_PASSWORD=Cixxxxxxx

Just to let you know that for some reason the credentials are not working today they were working over the weekend as Postman worked :) 

Try with https://sandboxsdwan.cisco.com:8443 in the browser. 

Hi eggy 

Credentials reset. We can log in with the devnetuser now 

Regards

Review Cisco Networking for a $25 gift card