WEBVTT

1
00:00.000 --> 00:05.200
So friends let's go and check out the REST API for Cisco DNA Center otherwise

2
00:05.200 --> 00:06.080
known as

3
00:06.080 --> 00:11.600
Catalyst Center. So as you may know as I like to do for exploring a REST API

4
00:11.600 --> 00:12.560
particularly for

5
00:12.560 --> 00:16.060
the very first time is just go straight to the documentation it's the best

6
00:16.060 --> 00:16.960
place to find that

7
00:16.960 --> 00:21.670
information. So if you happen to search for Cisco DNA Center REST API

8
00:21.670 --> 00:23.680
documentation let's go down to

9
00:23.680 --> 00:27.080
this link right here for the quick start and as we can see here this

10
00:27.080 --> 00:28.480
documentation gives you

11
00:28.480 --> 00:32.750
pretty much all you need to explore Cisco's DNA Center we have the general
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

11
00:28.480 --> 00:32.750
pretty much all you need to explore Cisco's DNA Center we have the general

12
00:32.750 --> 00:33.600
overview of the

13
00:33.600 --> 00:37.110
actual platform right here. You have examples so on so forth but the very first

14
00:37.110 --> 00:38.000
thing that I

15
00:38.000 --> 00:42.560
really want to focus in on is this concept right here of authentication. Really

16
00:42.560 --> 00:43.520
try to remember

17
00:43.520 --> 00:48.220
this when it comes to Cisco DNA Center's API we are going to be using a token

18
00:48.220 --> 00:49.440
based authentication

19
00:49.440 --> 00:54.620
pretty much what that means is that before we do anything we're going to have

20
00:54.620 --> 00:56.160
to get this token

21
00:56.160 --> 01:01.480
and once we have it we will use it in all the follow-up requests. So an example
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

21
00:56.160 --> 01:01.480
and once we have it we will use it in all the follow-up requests. So an example

22
01:01.480 --> 01:02.160
below what we

23
01:02.160 --> 01:06.210
actually have here is a Python script but in our case we're going to be doing

24
01:06.210 --> 01:07.360
this just simply

25
01:07.360 --> 01:10.930
utilizing Postman but there is some good information that we have right here.

26
01:10.930 --> 01:11.760
First thing I want you

27
01:11.760 --> 01:16.700
to notice this endpoint right here this is the endpoint we use when we want to

28
01:16.700 --> 01:18.000
get our token. Now

29
01:18.000 --> 01:22.490
when I say get or token this is the next thing that I want to highlight to you

30
01:22.490 --> 01:23.840
because intuitively

31
01:23.840 --> 01:28.580
when you want to get something and you're thinking of raised APIs you might

32
01:28.580 --> 01:29.680
well assume that we're

33
01:29.680 --> 01:33.610
going to be sending a get request in this case here this is not what we're
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

33
01:29.680 --> 01:33.610
going to be sending a get request in this case here this is not what we're

34
01:33.610 --> 01:35.040
going to do when we want

35
01:35.040 --> 01:39.470
to get a token we actually want to send a post request and I know it's kind of

36
01:39.470 --> 01:40.480
confusing not

37
01:40.480 --> 01:44.380
really the most intuitive thing but really really important to remember the

38
01:44.380 --> 01:45.920
post request is how we

39
01:45.920 --> 01:49.890
actually get that token and once we've got it well then they can really begin

40
01:49.890 --> 01:51.680
exploring the API.

41
01:51.680 --> 01:55.760
Now another point to note that we can see from this information is that the way

42
01:55.760 --> 01:56.480
we actually get

43
01:56.480 --> 02:01.010
this token it's not just a post request we send to this particular endpoint we
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

43
01:56.480 --> 02:01.010
this token it's not just a post request we send to this particular endpoint we

44
02:01.010 --> 02:02.640
also have to supply

45
02:02.640 --> 02:07.600
two vital pieces of information we're going to have HTTP basic authentication

46
02:07.600 --> 02:08.400
and that includes a

47
02:08.400 --> 02:15.060
username and password from that point we should effectively return a token key

48
02:15.060 --> 02:15.840
and inside that

49
02:15.840 --> 02:19.840
key will actually get the token that we can then use. Okay so again if we just

50
02:19.840 --> 02:20.800
scroll on down we're

51
02:20.800 --> 02:24.350
going to see information relating to the error codes the responses so on so

52
02:24.350 --> 02:25.680
forth if you so wish

53
02:25.680 --> 02:30.160
read this in your own time what I want to do now though as I want to use my
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

53
02:25.680 --> 02:30.160
read this in your own time what I want to do now though as I want to use my

54
02:30.160 --> 02:31.920
favorite tool to explore

55
02:31.920 --> 02:36.980
a raised API and that is postman we've seen this till before in earlier skills

56
02:36.980 --> 02:38.000
so let's just go

57
02:38.000 --> 02:43.020
and pull that up then so over on postman all I will do is choose new and I will

58
02:43.020 --> 02:44.880
create a HTTP

59
02:44.880 --> 02:49.160
request okay okay so the very first thing that we're going to have to do here

60
02:49.160 --> 02:50.080
is we are going to

61
02:50.080 --> 02:54.170
have to find an endpoint that we can actually target there's no point just

62
02:54.170 --> 02:55.600
sending these requests

63
02:55.600 --> 03:00.230
if we are not talking to Cisco DNA sensor now the best place to test out Cisco
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

63
02:55.600 --> 03:00.230
if we are not talking to Cisco DNA sensor now the best place to test out Cisco

64
03:00.230 --> 03:01.200
products if you

65
03:01.200 --> 03:05.140
don't actually have them on site and available to you is to go to the devnet

66
03:05.140 --> 03:06.080
sandbox so this

67
03:06.080 --> 03:10.450
is exactly what I'm going to do so once again let's go and pull up another

68
03:10.450 --> 03:11.920
window within our browser

69
03:11.920 --> 03:15.730
so let's search for Cisco devnet sandbox click on this right here and let me

70
03:15.730 --> 03:16.320
just zoom it a

71
03:16.320 --> 03:19.680
little bit so you can see it all you have to do is to log in and then choose to

72
03:19.680 --> 03:21.120
launch the sandbox

73
03:21.120 --> 03:25.980
now remember Cisco DNA center is now revamped and renamed as catalyst center so

74
03:25.980 --> 03:26.640
let's just search

75
03:26.640 --> 03:31.360
for center this is the one that I want to use the always on sandbox doesn't
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

75
03:26.640 --> 03:31.360
for center this is the one that I want to use the always on sandbox doesn't

76
03:31.360 --> 03:32.960
require any type of

77
03:32.960 --> 03:37.050
reservation so if I just click this here okay I'm just zoom out a little touch

78
03:37.050 --> 03:37.840
if we go to the

79
03:37.840 --> 03:41.720
access details here we can see this is how we actually access the sandbox in

80
03:41.720 --> 03:42.480
fact we can just

81
03:42.480 --> 03:47.570
test it out very briefly let's just copy this URL open up a new tab paste it in

82
03:47.570 --> 03:48.560
and what I'm going to

83
03:48.560 --> 03:52.100
do is I'm going to supply the information that I need to log in that's going to

84
03:52.100 --> 03:52.960
be the username

85
03:52.960 --> 03:57.910
and the password now if you can see here the username is devnet user so let's

86
03:57.910 --> 03:59.520
just paste this in and

87
03:59.520 --> 04:04.680
for the password it's simply as we can see right here Cisco 123 exclamation
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

87
03:59.520 --> 04:04.680
for the password it's simply as we can see right here Cisco 123 exclamation

88
04:04.680 --> 04:05.680
marks let's just copy

89
04:05.680 --> 04:10.500
this and paste your in let's log in and now we have access so obviously this is

90
04:10.500 --> 04:11.760
available to us the

91
04:11.760 --> 04:16.040
credentials are correct we don't want to log in though directly via the UI we

92
04:16.040 --> 04:17.280
want to be going

93
04:17.280 --> 04:21.060
and authenticating with postman to send these API requests so let's use that

94
04:21.060 --> 04:22.480
same information

95
04:22.480 --> 04:27.110
this time in postman so let's go back to our application right here what I'm

96
04:27.110 --> 04:27.760
going to do is

97
04:27.760 --> 04:33.280
I'm going to paste in the URL again just grab your right here copy and in order
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

97
04:27.760 --> 04:33.280
I'm going to paste in the URL again just grab your right here copy and in order

98
04:33.280 --> 04:34.080
to authenticate

99
04:34.080 --> 04:37.170
we're going to have to use a very particular endpoints remember from the

100
04:37.170 --> 04:38.640
documentation let me just

101
04:38.640 --> 04:42.640
pull us over a little touch scrolling on up let's go back to authentication

102
04:42.640 --> 04:43.680
look at the example

103
04:43.680 --> 04:47.750
this particular end point here is the one we want to append so let's copy this

104
04:47.750 --> 04:50.000
we go back here

105
04:50.000 --> 04:52.980
and just do forward slash paste that send a file that's an extra forward slash

106
04:52.980 --> 04:54.400
let's get rid of that

107
04:54.400 --> 05:00.040
and remember very important we don't want to send a get request we want to send
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

107
04:54.400 --> 05:00.040
and remember very important we don't want to send a get request we want to send

108
05:00.040 --> 05:01.200
a post request so

109
05:01.200 --> 05:04.320
let's make sure that's the case now also we're going to have to specify what

110
05:04.320 --> 05:05.280
our authorization is

111
05:05.280 --> 05:09.600
going to be we're going to use basic authentication so I will say DevNet user

112
05:09.600 --> 05:10.720
is going to be the login

113
05:10.720 --> 05:14.910
and the password will be Cisco 123 exclamation mark so if that's now done we

114
05:14.910 --> 05:16.080
have the post request

115
05:16.080 --> 05:20.590
we have the actual always on sandbox we're targeting the correct end point to

116
05:20.590 --> 05:21.440
get the token in

117
05:21.440 --> 05:26.300
of supplied the correct username and password with this now done we should be

118
05:26.300 --> 05:27.440
able to send off the

119
05:27.440 --> 05:30.990
request and get the response so let's just click send here all right so we
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

119
05:27.440 --> 05:30.990
request and get the response so let's just click send here all right so we

120
05:30.990 --> 05:32.320
actually get this token

121
05:32.320 --> 05:37.040
key back and more importantly we actually get the value of the token so let's

122
05:37.040 --> 05:38.720
just copy it this okay

123
05:38.720 --> 05:43.640
and from this point on we are going to use this value to make any subsequent

124
05:43.640 --> 05:44.800
request to Cisco

125
05:44.800 --> 05:48.460
DNA Center the actual request that you want to get information about the

126
05:48.460 --> 05:49.360
devices under the

127
05:49.360 --> 05:55.140
management of DNA Center so check this out all we'll do is create a new HTTP

128
05:55.140 --> 05:56.480
request once again

129
05:56.480 --> 06:01.050
no we do know we're going to be targeting the always on sandbox such as paste
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

129
05:56.480 --> 06:01.050
no we do know we're going to be targeting the always on sandbox such as paste

130
06:01.050 --> 06:02.880
this in as a base value

131
06:02.880 --> 06:06.470
for the authorization though this time we're actually going to get that by

132
06:06.470 --> 06:07.840
passing in values

133
06:07.840 --> 06:12.190
via our headers so here's what i'm going to do the key here and this is

134
06:12.190 --> 06:13.600
actually very important to

135
06:13.600 --> 06:18.360
remember if we happen to scroll further down looking at the python example

136
06:18.360 --> 06:19.440
right here what we're

137
06:19.440 --> 06:23.030
actually doing is presenting a get request to get information about IP

138
06:23.030 --> 06:24.400
addresses of a particular

139
06:24.400 --> 06:28.400
network device okay now within the headers we have two headers we have a

140
06:28.400 --> 06:29.600
content type header

141
06:29.600 --> 06:34.560
specifying we want JSON but this is the part that i really want to highlight in
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

141
06:29.600 --> 06:34.560
specifying we want JSON but this is the part that i really want to highlight in

142
06:34.560 --> 06:36.000
all of our requests

143
06:36.000 --> 06:40.810
we want to be supplying within the headers this particular key right here x off

144
06:40.810 --> 06:41.680
token and then

145
06:41.680 --> 06:46.350
the corresponding value will be the token that we just got in that previous

146
06:46.350 --> 06:47.440
request and from this

147
06:47.440 --> 06:51.190
point on this is how we're going to be allowed to get the information about

148
06:51.190 --> 06:52.800
this particular endpoints

149
06:52.800 --> 06:56.350
so let's go and just fill that information in right now the content type and

150
06:56.350 --> 06:57.520
the x off token

151
06:57.520 --> 07:05.760
so within the headers we'll just say x off token and the corresponding value
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

151
06:57.520 --> 07:05.760
so within the headers we'll just say x off token and the corresponding value

152
07:05.760 --> 07:06.640
all i will do is i'll

153
07:06.640 --> 07:11.480
paste in the token that i just got in the previous request so let's go here

154
07:11.480 --> 07:12.960
paste in this value

155
07:12.960 --> 07:16.400
there we go okay so we should have the information needed to make the request

156
07:16.400 --> 07:17.440
but what are the

157
07:17.440 --> 07:22.550
available endpoints once again we can find this directly from the documentation

158
07:22.550 --> 07:23.040
so if we just

159
07:23.040 --> 07:26.500
scroll on down we can see these other options in the left hand side so you want

160
07:26.500 --> 07:27.360
to get information

161
07:27.360 --> 07:31.520
about devices let's click this right here notice we have this option for end
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

161
07:27.360 --> 07:31.520
about devices let's click this right here notice we have this option for end

162
07:31.520 --> 07:33.120
points and methods

163
07:33.120 --> 07:36.720
used let's click this right here and see some examples so we've already seen

164
07:36.720 --> 07:37.520
this one right here

165
07:37.520 --> 07:41.400
we send a poster quest to get the authorization token we stole that token and

166
07:41.400 --> 07:42.240
then use it for

167
07:42.800 --> 07:46.660
these types of requests right here okay if we want to get information about

168
07:46.660 --> 07:47.920
network devices

169
07:47.920 --> 07:52.720
just generally we could grab this endpoints and remember now it's going to be a

170
07:52.720 --> 07:53.440
get request

171
07:53.440 --> 07:57.570
not a post request so let's paste in this new value make sure we're going to

172
07:57.570 --> 07:58.640
use a get request

173
07:58.640 --> 08:03.120
this time we have the x off token and with that now done if i just click send
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

173
07:58.640 --> 08:03.120
this time we have the x off token and with that now done if i just click send

174
08:03.120 --> 08:04.320
here we send off

175
08:04.320 --> 08:09.050
the request and now we actually get back a 200 status code okay so if we just

176
08:09.050 --> 08:10.160
go and inspect the

177
08:10.160 --> 08:14.550
response what we're actually seeing here are a whole bunch of different devices

178
08:14.550 --> 08:14.720
under the

179
08:14.720 --> 08:18.840
management of DNA center here is the first one right here the switch we can see

180
08:18.840 --> 08:19.760
it's MAC address

181
08:19.760 --> 08:24.340
right here and things like the software version the serial number of that

182
08:24.340 --> 08:25.760
device it's uptime so

183
08:25.760 --> 08:29.760
on so forth and if i just scroll on down we're going to eventually see we have

184
08:29.760 --> 08:30.720
another device
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

184
08:29.760 --> 08:30.720
another device

185
08:30.720 --> 08:34.290
under our control and this has a different MAC address with a different serial

186
08:34.290 --> 08:35.040
number so on

187
08:35.040 --> 08:39.400
so forth and again scrolling on down more and more devices under the management

188
08:39.400 --> 08:40.720
of Cisco DNA

189
08:40.720 --> 08:44.160
center and again if i want to get other information like go back to the

190
08:44.160 --> 08:45.520
documentation let's maybe

191
08:45.520 --> 08:49.910
say i want to i don't know let's go with health monitoring okay what can i do

192
08:49.910 --> 08:50.720
choose endpoints

193
08:50.720 --> 08:55.020
and methods use we can see we can send a get request to get network health let

194
08:55.020 --> 08:55.840
's grab this

195
08:55.840 --> 09:00.120
right here as we know as per the request the headers still have the x off token
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

195
08:55.840 --> 09:00.120
right here as we know as per the request the headers still have the x off token

196
09:00.120 --> 09:01.520
with this value

197
09:01.520 --> 09:06.160
all i will do now is send a get request change the end point paste this in and

198
09:06.160 --> 09:07.440
if i click send

199
09:07.440 --> 09:11.660
we send off the request we get the 200's data's code back and now this time we

200
09:11.660 --> 09:12.480
're getting different

201
09:12.480 --> 09:16.110
information related to the net work health and as we can see here we have a

202
09:16.110 --> 09:18.000
health score of 100

203
09:18.000 --> 09:22.740
so really as a recap when we're going to be interacting with the DNA center

204
09:22.740 --> 09:23.520
rest API we're

205
09:23.520 --> 09:28.000
going to have to first send a post request to gather a token for our

206
09:28.000 --> 09:29.920
authentication once we have

207
09:29.920 --> 09:34.880
this token we're going to pass it in to future requests with our headers and
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

207
09:29.920 --> 09:34.880
this token we're going to pass it in to future requests with our headers and

208
09:34.880 --> 09:35.600
the header is going

209
09:35.600 --> 09:40.570
to have this x off token key and then we pass in that particular value from

210
09:40.570 --> 09:41.920
this point on this is

211
09:41.920 --> 09:45.320
how we're going to make all of our requests this will be our validation so to

212
09:45.320 --> 09:46.080
speak and then all

213
09:46.080 --> 09:49.470
we do specify the end point that we want to target for the particular

214
09:49.470 --> 09:51.360
information that we want

215
09:51.360 --> 09:56.080
and then use the correct HTTP method whether it's a get request or post request

216
09:56.080 --> 09:57.040
we can find that

217
09:57.040 --> 10:00.900
information directly from a documentation by choosing the information that we
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

217
09:57.040 --> 10:00.900
information directly from a documentation by choosing the information that we

218
10:00.900 --> 10:02.160
want go to say for example

219
10:02.160 --> 10:06.350
path trace look at the end points and method used in the case here we have a

220
10:06.350 --> 10:07.680
post request correlating

221
10:07.680 --> 10:11.950
to this end point if you want to get flow analysis we can send a post request

222
10:11.950 --> 10:13.200
to make a change to

223
10:13.200 --> 10:16.720
our flow analysis right here if you want to delete information well we can

224
10:16.720 --> 10:18.160
target this particular end

225
10:18.160 --> 10:22.740
point this time with a delete request so on so forth but like i say the crucial

226
10:22.740 --> 10:24.480
point is that token

227
10:24.480 --> 10:27.040
is baked in to all of these requests.
