Now the process to install us on a mac is very similar.
You simply download the software and install it like any other software, so you download and install
the DMG file.
In this example, I've got some queries saved.
Now, I've told you, I'm going to show you this manually.
The only reason to save the queries is I don't have to manually type them and perhaps make mistakes.
So to save on the recording and save your time, I've prebuilt this, but here are all the steps.
The first thing we need when communicating with the DNA center server is a token.
There are different ways to implement authentication with a rest API.
In this example, they're using a token, which is a very popular way of doing it.
The idea with the token is I will authenticate to the server using a username and password.
A token will be given to me and that token is valid for a period of time.
And every time I make an API call, I send the token to the server to be authenticated.
In other words, to allow me to run the command against the rest API.
So first thing username and password needs to be sent.
Get back a token subsequent API calls, use the token rather than sending the username and password
in the API call.
Okay.
So this is the URL.
To get the token, i need to use a username of dev net user password is cisco 1 to 3 exclamation.
It's a post and then we need to copy back the token.
So as an example, if I try to use a get to get information from the DNA center server and I click send,
I'm getting token has expired.
Before I can get information from the server, I need to get a token.
It's not a get.
It's a post.
Post once again, allows me to create data structures and variables.
So your role is this?
I've put that in the PowerPoint slide once again.
Authorisation username is definite user password is Cisco 1 to 3 exclamation mark that's under the authorization
tab.
So if you were creating a new API call, you click on.
Plus at the top you specify what you're using.
Once again, it's a post.
Specify the URL, which I've got in the PowerPoint presentation, so I'm going to paste that in.
Notice we want to get a token from the server.
Authorization is basic authentication.
Different types of authorization are available here, including Birra, Token Digest, authentication,
oath, a signature and many others.
But basic authentication.
Username is dev.
Net user.
Password is Cisco.
One, two, three, exclamation.
So, Cisco.
One, two, three, exclamation.
Once you've done that, you can click send and we get a token back.
So once you've got your token, you need to copy this token.
So copy that token because we now going to use that for subsequent API calls.
So as an example, if we want to get information from the server, we need to use that token.
So let's get a list of devices from DNA Center.
Now once again looking at the API documentation, this API call get DNA intent API v one network device
gives us a list of devices.
So we told that it returns a list of network devices based on filter criteria such as IP address or
something else.
So we can filter this down or simply get a list of devices that have registered with DNA center.
Now, remember, DNA Center is talking down to network devices using different protocols on the southbound
API.
We are now querying the northbound API.
So we are using the northbound API to query DNA center.
CQ.
I've got a prebuilt API call, but again, let's create that manually so that you can see the full process.
What I need is the euro.
So this is a get.
And the URL.
Just click on the little plus shear if you want to create a new API call.
So it's a get.
Here's the URL or the URI.
We need to go to headers.
So headers here and we need to specify a key.
The key that we're going to create is content type.
So you need to specify content type.
And the key here is application JSON.
And then we need to specify x auth token.
This kind of stuff is going to basically be sent to the server when we make the API call.
So we're using rest API.
Think of it kind of like https.
We're making we're sending HTTPS information to the server saying get once again, it's kind of as an
analogy with a web page where I send a get and then I get back a web page, but I'm using an API and
I'm getting back other information from the server.
We're doing this manually, but once again, I'll show you later how to use a Python script to pull
this kind of information out of a router as an example.
So here we need our token.
So we need to copy that token from the previous post statement.
And I need to put my token in here.
Just make sure that you don't copy the inverted commas.
So copy only the API.
Okay.
So we've said it to get we've got our URL, we've set the content type to application JSON, we've set
the X auth token to the token that we received.
Click send.
And there you go.
We've now made an API call to a Cisco DNA center server using the northbound API.
So northbound to the controller, it's talking to network devices using the southbound API.
Here are some network devices that have registered with DNA center.
So as an example, we've got this Cisco ASR router.
Scrolling down, we've got this catalyst switch scrolling down.
Now the catalyst switch.
And once again, another switch.
Now what you can do is edit that API.
Remember?
What we've done here is we've connected to this part of the URL.
But what we can do is specify some parameters.
So we could specify as an example the type.
How do I know that?
Because yeah, we've got type and a name.
So I could type if I wanted to.
Question mark type equals Cisco ASR 1001 exe router.
That name, basically.
If I click send, all I get is the information for that router.
Not all the other riders.
I could specify software type.
So rather than doing it like that type software.
Type equals EOS XY.
Now it's remembered what I've typed previously, so that's why it's auto filling this in here.
In your case, you would have to manually type that.
But if I click send now I get the ASR rotor, but I also see the catalyst switch.
And other devices.
So it's basically pulled back all the devices that are using.
EOS xy.
Now you could specify something like Mac address, so I don't think I've used that previously.
So let's say Mac address equals and copy this notice we're using structured data here sent.
We only get to that ASR.
We don't get the other devices.
Notice it's ended here at line 46.
But if I removed that and simply looked at all devices, I get all the devices, we've got 169 lines
of output that's been returned.
You could do something like this, say platform.
So simply put a question mark at the end there.
Remove this information that's not required equals what we're looking for.
Click send and there we go.
We only get back that switch.
So there you go.
That's an example of using a rest API.
We did a post to get back our token, so we retrieved a token and then we used gets to retrieve information
from the server.
Again, how do you know what you should be using that's available in the rest API documentation?
So as an example, a authentication.
It's a post to get the authentication.
The developers would have written this API, they build the API.
We told the code when we successful or when it's invalid credentials.
So as an example, if I went back here and try to do a post and I put the wrong password in, I would
get authentication as failed.
Please provide valid credentials.
Notice the code is for one unauthorized.
Put the right password in.
Click send.
We get the token back and it'll be a different token every time you make this API call.
A token is valid for a period of time that they decide.
So it really depends on what the developer has decided to do.
Again, this get statement allows me to get devices.
If I made a mistake, I would get errors.
So 200 is success.
Let's go back over here.
Click Send notice 200.
Everything is good.
So we made no mistakes.
But if I change this to, let's say, network device.
So I broke the API.
Your role here, I'm getting 404 error not found.
Now to help you with your errors, I've put some errors in this PowerPoint presentation.
So 200 Life is good.
Just demonstrated that four one is unauthorized, token is not used.
So again, if I deleted this token, so let's delete that token.
So I'll cut it and click send.
We've got a41 error unauthorized bad token.
Put that in send.
We're getting technical name network devices not found for oh four because this is wrong.
It has to be network hyphen or dash device.
Now we get 200, everything is good.
So you can see very easily what error messages have been returned if you made a mistake.
Okay, here's a 400 error.
Once again, if I say network device 1 to 3.
So once again, if I do that.
So I've made it.
One, two, three.
Here.
Click Send four bad request.
And we're told one, two, three is not a valid UUID of a device.
If I did this notice I removed the question mark by mistake.
We told invalid characters.
So this needs to have a question mark there.
Click send.
Now we get to the correct data back.
Four four is probably one of the most famous ones that you've seen.
Here's a screenshot of me going to Cisco's website and just typing some random stuff.
So let's do that.
Go to Cisco dot com and type.
Just some random nonsense notice for for error.
That page doesn't exist.
So you might have seen this many times on the internet.
We could do something similar with the rest API.
So once again, I'll specify a network device like that for for error.
Not found very common error when you've made a mistake with your URL.
Now you may be thinking, but David, I could just use a CLI to do this.
Just remember where we going?
This is just the initial baby steps.
I want to show you how you can query an API, how you can get information back using a visual application.
This is a great application for testing the API, getting used to the API, making sure that everything
works properly and then you can put it into code.
I'm going to show you this Python script once again where I run a script on my local computer and query
a API on a Cisco router, iSCSI rod in this case and get information back.
So just remember where we going, baby steps learn.
When you write in the beginning you learned enable, you learn confetti.
But as you get more and more confident, you'll learn more and more complex things.
Same thing here.
You don't have to learn Python for the exam, but just remember, that's where we going.
We're using this tool to learn about the API and learning how to interact with the API, but that's
not where we want to end.