- [Instructor] Welcome.
In this sublesson, 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 DNA Center APIs
is to first authenticate the user.
So in this example, we are using a sandbox
which is available at DevNet, or Cisco's Developers 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, specify 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 DNA center accepts all incoming data
in the REST API code, which is in the JSON format.
So you need to make sure that the data
is coming in JSON format, and the result
is also going to be in the JSON format.
So we have this data 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 DNA Center.
So now we can go to another tab
and say we 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/version1/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 DNA Center only accepts JSON format of data.
And another key that we'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 a request, the GET request,
it will fetch all the information from the device itself
or from the the DNAC appliance and give you the result.
Now, let's see, how does the code looks like,
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 9300 switch,
which we can see here,
and we also have another Catalyst 9300 switch,
and we can also see their management IP addresses.
So 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 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 have performed.
So all these basic things that you need to remember
to make sure you have successful authentication
and 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 access.