Rather than interacting with DNA center, let's just talk directly to a router.
The advantage of using DNA centers, you can talk to a controller that's then managing many, many devices,
but you can also talk directly to a device if it supports a rest API.
So in this example, we're going to use the Cisco dev net, iOS, ESXi, always on sandbox.
It uses this URL.
This is its DNS name.
This is the protocol that we're going to use port number, username, password, and we're going to
use Postman once again.
Now, very important.
Before you do anything else.
And I want to show you this in both windows and on a mac in Postman.
Go to file on your Windows installation settings and make sure that you turn off SSL certificate verification.
The route in this example is using a self signed certificate.
If you don't turn this off, it's not going to work.
You're going to drive yourself crazy.
You have to override self signed certificates to make this work.
On a mac.
You need to go to postman preferences and disable SSL certificate verification.
Before you do anything else, make sure you've done that.
Otherwise, you're going to drive yourself crazy.
So I've got.
Some pre-built stuff here.
But again, let's not use that.
Let's do stuff.
Manually so that you can see how it works.
I'll close all these tabs.
New Tab.
Untitled Request.
First thing I want to do is get a list of interfaces on the router.
This is the URL that I'm going to use.
So I'm simply going to paste that in here.
It's a get statement we're using.
Get your roll.
Is that.
But we need to put our authorization information in.
It's basic authentication.
You can see that here in the PowerPoint slide.
Username is developer password of Cisco.
One, two, three, four, five with a second character being a one.
So we're going to use developer as our username password.
Is that.
This should connect to that router and give us a list of interfaces on the router.
Notice it's returned the information in this example in XML format.
So I can see gigabit one.
This is the management interface.
Don't touch it.
IP addresses this net mask is this will subnet mask is that.
Here's another interface that was configured by rest.
Someone else is configuring this, so this isn't always on sandbox so anyone can connect to this.
So you'll see other people creating stuff on the router.
Now XML like this isn't that easy for us as a human to read.
You can see someone has added loopback 100 year using risk conf someone has added in this example loopback
103 using the client net mico someone has also added a loopback of 200 using python.
XML isn't the easiest to read.
Let's rather change this to JSON formatting.
So to do that I'm going to go to headers and what we're going to do is create a key called accept.
And the value of that key is going to be application yang hyphen data plus JSON so that.
And then I'm going to click Send.
And notice we've got Jason formatting now rather than XML formatting.
That's probably a lot easier to read for us as humans so we can see IETF interfaces.
Notice this is an array of square brackets there.
Gigabit interfaces.
This we're told not to touch it.
There's the IP address.
Here's interface gigabit two configured by Hy-Vee with his information.
Here's gigabit to 100 and other interfaces that have been added.
You can see suddenly we've got loopback.
ADHD.
So there are other people once again working on this.
He has loopback 99.
Loopback 100.
So once again, other people are configuring this device.
But there you go.
That is an example of using rest to connect to a browser and retrieve information back.
Notice we using HTTPS, we are not using net configure.
We're not using SSH, we're using https rest API call.
Now one thing I'll say is if you have problems, then add the second key.
So if you have problems where it doesn't send back the information, then add the second key.
But in my tests it's not required, but it will be required when you want to add an interface.
So in the PowerPoint slide, once again, I've given you all that information, but now let's use a
post and let's add an interface.
So post will allow us to add something.
So click on this tab, put the URL in.
It's a post.
We need to use the same username and password so not a get but post.
Go to authorization.
In this example, we're using basic authentication.
On DNA center, we were using tokens.
So X auth tokens for authorization.
Here we are using.
Basic authentication.
So username is developer password Cisco one, two, three, four, five.
That's correct.
We need to go to headers and we need to add two headers.
Share key.
One is accept.
Once again, we want to use JSON.
And we're going to do the same thing again for Key too.
But Key too is going to be content type.
This kind of stuff is determined by the developer.
In other words, by the API.
If you want to interact with an API, you need to send the information as required by that API.
And the developers of that API will decide what that API requires.
So don't worry too much about what the values are.
This is the API developed by the Cisco iOS X people and we interacting with that API now.
Now step three is we need to add this to the body because we want to create a specific interface.
We need to tell the router what interface we want to create.
So to do that, we're going to use this text in the body of our API call.
So go to body, go to raw and paste this in now because other people just go back to get our creating
interfaces on this.
Rather, I've specifically used a high end loopback number so that I'm not interfering with what they're
doing and they're not interfering with what I'm doing.
So I'm going to create a loopback of one, two, three, four and say that this was added using rest
conf IP address is going to be one, two, three, four subnet mask is going to be slash 32.
So if I go back to the get statement and click send notice that loopback doesn't exist on the router.
We've got some physical interfaces.
We've got some loop backs, but we don't have a loopback.
One, two, three, four.
So back to our post.
I've put the URL in.
Authorization is basic authorization using developer password of Cisco headers are specified except
and content type body.
I've put this information in.
Click send.
We have got 201 request has been fulfilled and resulted in a new resource being created.
That's good.
So let's confirm the results.
So go back to get click send.
Scroll down and notice.
Here's our loopback interface.
Now, if I try to create that again, I'm getting an error for one conflict object already exists,
so I've already got that interface so I can't create it.
But if I created another one, let's create a loopback.
One, two, three, five and click send.
We've got two of one created.
Go back to get.
Click send notice.
One, two, three, five exists and so does.
One, two, three, four.
So there's is an example of creating a loopback interface on a router using a rest API direct connection
to the rest API of the router.
Okay.
So I've once again put that in the PowerPoint presentation for you.
Let's delete that loopback.
So I'm going to create a new tab here.
But this is a delete your URL.
Is that notice at the end here?
I've specified the interface that I want to delete.
Authorization is going to be basic authorization.
Using our credentials, we have to have a key of accept.
So go to headers key of accept.
Here application is Yang data plus JSON Click send.
We told that there's no content.
Let's do a send again here.
Notice the interface has been deleted.
Let's change that to interface.
One, three, four, five.
I should have checked that first.
I'll do it again in a moment.
But notice she has one, two, three, five.
So that exists.
One, two, three, four is deleted.
But let's delete.
One, two, three, five.
No content has been returned.
That's correct.
So back on our get click send.
Notice one, three, five is gone.
Let's create one, two, three, four once again.
If you want to, you can duplicate this tab.
So now I've got two posts and what I could do is to oppose for one, two, three, four, and.
One, two, three, four, five.
So let's create.
So it's a post.
Let's create a loopback.
One, two, three, four.
It's created now.
So back on our get statement.
Click send.
Notice one, two, three, four has been created.
Let's create one, two, three, five, click send.
It says created.
That's good.
Do get to gain it's created.
But if I delete in this case.
One, two, three, four.
Click send.
No content returned.
Previously that loopback was created.
But now it's gone.
We've got loopback 200 and then loopback.
One, two, three, five.
One, two, three, four has gone.
Let's delete.
One, two, three, five.
Click send.
To get once again notice that loopback has gone.
So I've shown you now how to use Postman to interact directly with a router and find out the interfaces
on the router.
Create a new interface as well as delete an interface rest APIs.
That is an example of using rest APIs on an individual device, but I've also shown you previously how
to do that with DNA center.
So DNA center once again, rest API allows me to interact with a whole bunch of devices.
Here I am interacting with one device.
Now the comment I always get is David I could just use the clay might be quicker, but don't forget
that with programming you can scale.
So I'm going to show you now how to get to the interfaces of one router.
But if I had 200 routers, I could write a Python script with a loop.
No human would be able to compete with a Python script written properly or an Ansible script written
properly where it's connecting to many devices and doing things on many devices.
You may be quick on one device, but if I write my script right, there's no way a human can compete
if I've got 100 or 200 devices or 1000 devices.
Okay.
So let me show you the Python script.