1
00:00:06,490 --> 00:00:08,130
Welcome, in the sub lesson,

2
00:00:08,130 --> 00:00:09,270
we are going to see

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

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

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

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

7
00:00:21,390 --> 00:00:25,360
So in this example, we are using a Sandbox

8
00:00:25,360 --> 00:00:27,710
which is available at DevNet

9
00:00:27,710 --> 00:00:31,011
or the Develop Cisco's
developers library network.

10
00:00:31,011 --> 00:00:34,041
And there we can access
the Sandbox for DNAC

11
00:00:34,041 --> 00:00:35,681
and use this path,

12
00:00:35,681 --> 00:00:40,681
which is
sandboxdnac.cisco.com/api/system/v1/auth/token.

13
00:00:45,860 --> 00:00:48,950
And once we have specified the whole path

14
00:00:48,950 --> 00:00:51,640
in order to authenticate,
then we can move on

15
00:00:51,640 --> 00:00:56,470
to the authorization section
and select the Auth type

16
00:00:56,470 --> 00:00:59,460
as the basic Auth.

17
00:00:59,460 --> 00:01:01,410
Once you have done that,
specified the username

18
00:01:01,410 --> 00:01:05,560
and password and once you do
that, you can send the request.

19
00:01:05,560 --> 00:01:07,260
Once you send the request.

20
00:01:07,260 --> 00:01:11,687
Now, an important note
that the DNS Center accepts

21
00:01:11,687 --> 00:01:14,560
all incoming data and the REST API code,

22
00:01:14,560 --> 00:01:16,590
which is in the JSON format.

23
00:01:16,590 --> 00:01:19,290
So you can make sure
that the data is coming

24
00:01:19,290 --> 00:01:21,510
in JSON format, the result is also going

25
00:01:21,510 --> 00:01:23,260
to be in the JSON format.

26
00:01:23,260 --> 00:01:25,470
So we have this data as a,

27
00:01:25,470 --> 00:01:26,680
with the key token

28
00:01:26,680 --> 00:01:28,100
and this is the key.

29
00:01:28,100 --> 00:01:33,100
Now this key is what is used
for accessing the authorized

30
00:01:34,180 --> 00:01:38,150
or authenticated APIs in the DNS Center.

31
00:01:38,150 --> 00:01:40,340
So now we can go to that other tab

32
00:01:40,340 --> 00:01:43,480
and say they are going to fetch some data

33
00:01:43,480 --> 00:01:47,416
we are going to use the path HTTPS

34
00:01:47,416 --> 00:01:48,640
and this path.

35
00:01:48,640 --> 00:01:49,473
So we have

36
00:01:49,473 --> 00:01:54,280
this sandboxdnac.cisco.com/api/v1/network
device.

37
00:01:55,840 --> 00:01:57,700
And under the headers

38
00:01:57,700 --> 00:02:00,400
we are going to have some key value pairs.

39
00:02:00,400 --> 00:02:03,190
Now, so the first content,
well, the first key

40
00:02:03,190 --> 00:02:05,440
that we are going to
have is the content type

41
00:02:06,320 --> 00:02:08,800
and this content type
should have the value

42
00:02:08,800 --> 00:02:12,720
of application/JSON.

43
00:02:12,720 --> 00:02:14,450
Why, because the DNS Center

44
00:02:14,450 --> 00:02:17,640
only accepts JSON format of data.

45
00:02:17,640 --> 00:02:18,910
And the another key

46
00:02:18,910 --> 00:02:23,910
that you're going to
create is the X-Auth-token.

47
00:02:26,950 --> 00:02:31,560
And this is going to
have a value of the key

48
00:02:31,560 --> 00:02:34,840
that you have fetched or copied

49
00:02:34,840 --> 00:02:36,470
from the other API,

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

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

52
00:02:42,470 --> 00:02:45,640
and now when you try to send the request,

53
00:02:45,640 --> 00:02:46,580
the GET request

54
00:02:46,580 --> 00:02:49,343
you will fetch, it will
fetch all the information

55
00:02:49,343 --> 00:02:53,070
from the device itself

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

57
00:02:58,710 --> 00:03:00,660
Now let see how does the code looks like.

58
00:03:00,660 --> 00:03:02,290
So or the output looks like.

59
00:03:02,290 --> 00:03:03,440
So we have the response,

60
00:03:03,440 --> 00:03:06,680
we have the type as ASR 1001 X router,

61
00:03:06,680 --> 00:03:08,900
which is connected to the DNAC.

62
00:03:08,900 --> 00:03:11,899
Another one, we have the
catalyst 9,300 Switch

63
00:03:11,899 --> 00:03:13,420
which we can see here.

64
00:03:13,420 --> 00:03:17,800
And we also have another
catalyst 9,300 Switch

65
00:03:18,950 --> 00:03:22,650
and we can also see their
Management IP addresses.

66
00:03:22,650 --> 00:03:25,270
All that information can be seen

67
00:03:25,270 --> 00:03:27,240
from the network device API.

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

69
00:03:30,690 --> 00:03:33,960
Now, if you try to access
any of an (mumbles)

70
00:03:33,960 --> 00:03:38,060
or a resource or an API,
which does not exist

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

72
00:03:43,390 --> 00:03:47,810
such as 404 not found or
an unauthenticated API

73
00:03:47,810 --> 00:03:49,870
in case you are trying
to access a resource

74
00:03:49,870 --> 00:03:53,140
but you have forgotten
to specify the token

75
00:03:53,140 --> 00:03:56,480
which you have received
based on the authentication

76
00:03:56,480 --> 00:03:57,530
that you've performed.

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

78
00:04:00,540 --> 00:04:03,020
to make sure you have
successful authentication

79
00:04:03,020 --> 00:04:05,810
and you can, you're
trying to access an API

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

81
00:04:09,060 --> 00:04:11,680
not an API, which does not exist

82
00:04:11,680 --> 00:04:14,280
or tries to access a resource,
which does not exist.

