Welcome, in the sub lesson,
we are going to see
how to access the Cisco DNA Center APIs,
for that let's switch on to the Postman.
The first step to access the DNS Center APIs
is to first authenticate the user.
So in this example, we are using a Sandbox
which is available at DevNet
or the Develop Cisco's developers library network.
And there we can access the Sandbox for DNAC
and use this path,
which is sandboxdnac.cisco.com/api/system/v1/auth/token.
And once we have specified the whole path
in order to authenticate, then we can move on
to the authorization section and select the Auth type
as the basic Auth.
Once you have done that, specified the username
and password and once you do that, you can send the request.
Once you send the request.
Now, an important note that the DNS Center accepts
all incoming data and the REST API code,
which is in the JSON format.
So you can make sure that the data is coming
in JSON format, the result is also going
to be in the JSON format.
So we have this data as a,
with the key token
and this is the key.
Now this key is what is used for accessing the authorized
or authenticated APIs in the DNS Center.
So now we can go to that other tab
and say they are going to fetch some data
we are going to use the path HTTPS
and this path.
So we have
this sandboxdnac.cisco.com/api/v1/network device.
And under the headers
we are going to have some key value pairs.
Now, so the first content, well, the first key
that we are going to have is the content type
and this content type should have the value
of application/JSON.
Why, because the DNS Center
only accepts JSON format of data.
And the another key
that you're going to create is the X-Auth-token.
And this is going to have a value of the key
that you have fetched or copied
from the other API,
the token value that you copied from the API request.
So you have put down the key here
and now when you try to send the request,
the GET request
you will fetch, it will fetch all the information
from the device itself
or from the DNAC appliance and give you the result.
Now let see how does the code looks like.
So or the output looks like.
So we have the response,
we have the type as ASR 1001 X router,
which is connected to the DNAC.
Another one, we have the catalyst 9,300 Switch
which we can see here.
And we also have another catalyst 9,300 Switch
and we can also see their Management IP addresses.
All that information can be seen
from the network device API.
There are other APIs as well that you can try to access.
Now, if you try to access any of an (mumbles)
or a resource or an API, which does not exist
in those cases you might see different HTTP error codes,
such as 404 not found or an unauthenticated API
in case you are trying to access a resource
but you have forgotten to specify the token
which you have received based on the authentication
that you've performed.
So all these basic things that you need to remember
to make sure you have successful authentication
and you can, you're trying to access an API
or make a call to an API, which gives you a proper result
not an API, which does not exist
or tries to access a resource, which does not exist.