1
00:00:06,510 --> 00:00:07,350
- [Instructor] Welcome.

2
00:00:07,350 --> 00:00:09,240
In this sublesson, we are going to see

3
00:00:09,240 --> 00:00:13,260
how to access the Cisco DNA Center APIs.

4
00:00:13,260 --> 00:00:16,020
For that, let's switch on to the Postman.

5
00:00:16,020 --> 00:00:18,630
The first step to access
the DNA Center APIs

6
00:00:18,630 --> 00:00:21,390
is to first authenticate the user.

7
00:00:21,390 --> 00:00:24,825
So in this example, we are using a sandbox

8
00:00:24,825 --> 00:00:29,825
which is available at DevNet,
or Cisco's Developers Network,

9
00:00:30,420 --> 00:00:34,080
and there we can access
the sandbox for DNAC

10
00:00:34,080 --> 00:00:36,650
and use this path, which is

11
00:00:36,650 --> 00:00:41,650
sandboxdnac.cisco.com/api/system/v1/auth/token.

12
00:00:45,840 --> 00:00:48,930
And once we have specified the whole path

13
00:00:48,930 --> 00:00:51,630
in order to authenticate,
then we can move on

14
00:00:51,630 --> 00:00:53,220
to the authorization section

15
00:00:53,220 --> 00:00:58,220
and select the auth
type as the basic auth.

16
00:00:59,460 --> 00:01:02,880
Once you have done that, specify
the username and password,

17
00:01:02,880 --> 00:01:05,550
and once you do that,
you can send the request.

18
00:01:05,550 --> 00:01:08,760
Once you send the request,
now, an important note

19
00:01:08,760 --> 00:01:13,320
that the DNA center
accepts all incoming data

20
00:01:13,320 --> 00:01:16,590
in the REST API code, which
is in the JSON format.

21
00:01:16,590 --> 00:01:18,660
So you need to make sure that the data

22
00:01:18,660 --> 00:01:20,820
is coming in JSON format, and the result

23
00:01:20,820 --> 00:01:23,250
is also going to be in the JSON format.

24
00:01:23,250 --> 00:01:26,670
So we have this data with the key token,

25
00:01:26,670 --> 00:01:28,110
and this is the key.

26
00:01:28,110 --> 00:01:30,690
Now, this key is what is used

27
00:01:30,690 --> 00:01:35,690
for accessing the authorized
or authenticated APIs

28
00:01:36,140 --> 00:01:38,160
in the DNA Center.

29
00:01:38,160 --> 00:01:40,380
So now we can go to another tab

30
00:01:40,380 --> 00:01:43,620
and say we are going to fetch some data.

31
00:01:43,620 --> 00:01:48,620
We are going to use the
path HTTPs and this path.

32
00:01:48,660 --> 00:01:49,530
So we have this

33
00:01:49,530 --> 00:01:54,530
sandboxdnac.cisco.com/api/version1/network-device,

34
00:01:55,860 --> 00:01:57,720
and under the headers,

35
00:01:57,720 --> 00:02:00,390
we are going to have some key-value pairs.

36
00:02:00,390 --> 00:02:03,180
Now, so the first content,
well, the first key

37
00:02:03,180 --> 00:02:05,480
that we are going to
have is the content type,

38
00:02:06,330 --> 00:02:08,790
and this content type
should have the value

39
00:02:08,790 --> 00:02:12,720
of application/json.

40
00:02:12,720 --> 00:02:13,553
Why?

41
00:02:13,553 --> 00:02:17,640
Because the DNA Center only
accepts JSON format of data.

42
00:02:17,640 --> 00:02:19,830
And another key that we're going to create

43
00:02:19,830 --> 00:02:24,813
is the X-Auth-Token, and
this is going to have a value

44
00:02:29,880 --> 00:02:33,480
of the key that you have fetched

45
00:02:33,480 --> 00:02:36,450
or copied from the other API,

46
00:02:36,450 --> 00:02:39,540
the token value that you
copied from the API request.

47
00:02:39,540 --> 00:02:42,480
So you have put down the key here,

48
00:02:42,480 --> 00:02:47,480
and now, when you try to send
a request, the GET request,

49
00:02:47,550 --> 00:02:52,550
it will fetch all the information
from the device itself

50
00:02:53,070 --> 00:02:58,070
or from the the DNAC appliance
and give you the result.

51
00:02:58,710 --> 00:03:00,920
Now, let's see, how does
the code looks like,

52
00:03:00,920 --> 00:03:02,280
or the output looks like?

53
00:03:02,280 --> 00:03:03,420
So we have the response,

54
00:03:03,420 --> 00:03:06,750
we have the type as ASR-1001-X router,

55
00:03:06,750 --> 00:03:08,910
which is connected to the DNAC.

56
00:03:08,910 --> 00:03:12,300
Another one, we have the
Catalyst 9300 switch,

57
00:03:12,300 --> 00:03:13,440
which we can see here,

58
00:03:13,440 --> 00:03:17,853
and we also have another
Catalyst 9300 switch,

59
00:03:18,960 --> 00:03:22,500
and we can also see their
management IP addresses.

60
00:03:22,500 --> 00:03:25,260
So all that information can be seen

61
00:03:25,260 --> 00:03:27,240
from the network device API.

62
00:03:27,240 --> 00:03:30,690
There are other APIs as well
that you can try to access.

63
00:03:30,690 --> 00:03:35,640
Now, if you try to
access any of a resource

64
00:03:35,640 --> 00:03:38,070
or an API which does not exist,

65
00:03:38,070 --> 00:03:43,070
in those cases, you might see
different HTTP error codes,

66
00:03:43,440 --> 00:03:47,880
such as 404 not found, or
an unauthenticated API,

67
00:03:47,880 --> 00:03:49,860
in case you are trying
to access a resource,

68
00:03:49,860 --> 00:03:53,160
but you have forgotten
to specify the token

69
00:03:53,160 --> 00:03:56,460
which you have received
based on the authentication

70
00:03:56,460 --> 00:03:57,540
that you have performed.

71
00:03:57,540 --> 00:04:00,540
So all these basic things
that you need to remember

72
00:04:00,540 --> 00:04:03,060
to make sure you have
successful authentication

73
00:04:03,060 --> 00:04:05,790
and you're trying to access an API

74
00:04:05,790 --> 00:04:09,060
or make a call to an API which
gives you a proper result,

75
00:04:09,060 --> 00:04:11,229
not an API which does not exist

76
00:04:11,229 --> 00:04:14,643
or tries to access a resource
which does not access.

