WEBVTT

1
00:00.000 --> 00:04.560
So let's now look at how we can use the REST API for Cisco's SD1.

2
00:04.560 --> 00:09.560
Now I will say there are some similarities to the SD1 REST API with what we saw

3
00:09.560 --> 00:10.400
in DNA

4
00:10.400 --> 00:11.400
center.

5
00:11.400 --> 00:14.600
We're going to have to deal with authentication, so we'll be dealing with

6
00:14.600 --> 00:16.200
passing in our username

7
00:16.200 --> 00:17.400
and password credentials.

8
00:17.400 --> 00:20.040
But there are some subtle differences.

9
00:20.040 --> 00:23.520
So with that said, let's dive in and see a dimension.

10
00:23.520 --> 00:28.270
So if you happen to search for Cisco's SD1 REST API documentation, let's click

11
00:28.270 --> 00:28.640
this link

12
00:28.640 --> 00:29.640
here.

13
00:29.640 --> 00:32.720
Then as we can see, then the left hand side, we have our options.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

13
00:29.640 --> 00:32.720
Then as we can see, then the left hand side, we have our options.

14
00:32.720 --> 00:36.160
If I go to authentication right here, we can see here straight away, we're

15
00:36.160 --> 00:36.720
going to have

16
00:36.720 --> 00:39.040
to log in with a username and a password.

17
00:39.040 --> 00:41.320
But here is something quite unique.

18
00:41.320 --> 00:45.420
We're going to have to specify the username and the password and submit them in

19
00:45.420 --> 00:46.400
this particular

20
00:46.400 --> 00:47.400
form.

21
00:47.400 --> 00:50.800
J_Username and J_Password.

22
00:50.800 --> 00:53.400
This is essentially with reference to Java.

23
00:53.400 --> 00:55.680
Java username, Java password.

24
00:55.680 --> 00:59.470
And essentially, that will give us a token with which we can use to authent

25
00:59.470 --> 01:00.080
icate going
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

25
00:59.470 --> 01:00.080
icate going

26
01:00.080 --> 01:01.080
forward.

27
01:01.080 --> 01:06.600
But this is going to come in the form of an HTTP cookie, the J session ID or

28
01:06.600 --> 01:07.760
the Java session

29
01:07.760 --> 01:08.760
ID.

30
01:08.760 --> 01:11.680
Next point, which is very, very important.

31
01:11.680 --> 01:16.320
Remember with respect to DNA center, we had to specify a particular header.

32
01:16.320 --> 01:19.800
And that header was our XAuth token.

33
01:19.800 --> 01:24.680
In the case with Cisco's SD1, we do not specify this.

34
01:24.680 --> 01:29.200
We instead use a content type header, but the value we provide is going to be

35
01:29.200 --> 01:29.960
application

36
01:29.960 --> 01:34.800
forward slash X www form URL encoded.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

36
01:29.960 --> 01:34.800
forward slash X www form URL encoded.

37
01:34.800 --> 01:38.650
So this here is a big distinction between the operation of these two different

38
01:38.650 --> 01:39.120
APIs.

39
01:39.120 --> 01:41.000
So let's begin getting hands on.

40
01:41.000 --> 01:44.160
And then what I will first do is go to the DevNet sandbox.

41
01:44.160 --> 01:46.400
And in this case here, I'm going to look for SD1.

42
01:46.400 --> 01:50.520
If I set it for SD, we can actually see I have the always on sandbox.

43
01:50.520 --> 01:51.680
Let's click this here.

44
01:51.680 --> 01:55.800
And again, if we go to the access details, we can see this is the URL.

45
01:55.800 --> 02:00.160
If I just copy this here, paste you in, I'll just go to advanced and I will
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

45
01:55.800 --> 02:00.160
If I just copy this here, paste you in, I'll just go to advanced and I will

46
02:00.160 --> 02:00.920
click this

47
02:00.920 --> 02:01.920
link here.

48
02:01.920 --> 02:05.480
And now I can log in with the username, which again is DevNet user.

49
02:05.480 --> 02:07.160
And we also have this password here.

50
02:07.160 --> 02:09.840
So let's copy this to DevNet user.

51
02:09.840 --> 02:11.720
And then the password, let's log in.

52
02:11.720 --> 02:12.720
All right.

53
02:12.720 --> 02:13.720
So we log in.

54
02:13.720 --> 02:16.720
We'll go to the end of the course.

55
02:16.720 --> 02:18.720
And then we'll go to the end of the course.

56
02:18.720 --> 02:20.720
And then we'll go to the end of the course.

57
02:20.720 --> 02:22.720
And then we'll go to the end of the course.

58
02:22.720 --> 02:24.720
And then we'll go to the end of the course.

59
02:24.720 --> 02:25.720
And then we'll go to the end of the course.

60
02:25.720 --> 02:27.720
And then we'll go to the end of the course.

61
02:27.720 --> 02:28.720
And then we'll go to the end of the course.

62
02:28.720 --> 02:29.720
And then we'll go to the end of the course.

63
02:29.720 --> 02:30.720
And then we'll go to the end of the course.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

63
02:29.720 --> 02:30.720
And then we'll go to the end of the course.

64
02:30.720 --> 02:31.720
And then we'll go to the end of the course.

65
02:31.720 --> 02:32.720
And then we'll go to the end of the course.

66
02:32.720 --> 02:33.720
And then we'll go to the end of the course.

67
02:33.720 --> 02:34.720
And then we'll go to the end of the course.

68
02:34.720 --> 02:35.720
And then we'll go to the end of the course.

69
02:35.720 --> 02:45.720
And then we'll go to the end of the course.

70
02:45.720 --> 02:46.720
And then we'll go to the end of the course.

71
02:46.720 --> 02:47.720
And then we'll go to the end of the course.

72
02:47.720 --> 02:48.720
And then we'll go to the end of the course.

73
02:48.720 --> 02:49.720
And then we'll go to the end of the course.

74
02:49.720 --> 02:50.720
And then we'll go to the end of the course.

75
02:50.720 --> 02:51.720
And then we'll go to the end of the course.

76
02:51.720 --> 02:52.720
And then we'll go to the end of the course.

77
02:52.720 --> 02:53.720
And then we'll go to the end of the course.

78
02:53.720 --> 02:54.720
And then we'll go to the end of the course.

79
02:54.720 --> 02:55.720
And then we'll go to the end of the course.

80
02:55.720 --> 02:56.720
And then we'll go to the end of the course.

81
02:56.720 --> 02:57.720
And then we'll go to the end of the course.

82
02:57.720 --> 02:58.720
And then we'll go to the end of the course.

83
02:58.720 --> 02:59.720
And then we'll go to the end of the course.

84
02:59.720 --> 03:04.720
And then we'll go to the end of the course.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

84
02:59.720 --> 03:04.720
And then we'll go to the end of the course.

85
03:04.720 --> 03:11.720
And then we'll go to the end of the course.

86
03:11.720 --> 03:12.720
And then we'll go to the end of the course.

87
03:12.720 --> 03:13.720
And then we'll go to the end of the course.

88
03:13.720 --> 03:14.720
And then we'll go to the end of the course.

89
03:14.720 --> 03:15.720
And then we'll go to the end of the course.

90
03:15.720 --> 03:16.720
And then we'll go to the end of the course.

91
03:16.720 --> 03:17.720
And then we'll go to the end of the course.

92
03:17.720 --> 03:18.720
And then we'll go to the end of the course.

93
03:18.720 --> 03:19.720
And then we'll go to the end of the course.

94
03:19.720 --> 03:20.720
And then we'll go to the end of the course.

95
03:20.720 --> 03:21.720
And then we'll go to the end of the course.

96
03:21.720 --> 03:22.720
And then we'll go to the end of the course.

97
03:22.720 --> 03:23.720
And then we'll go to the end of the course.

98
03:23.720 --> 03:24.720
And then we'll go to the end of the course.

99
03:24.720 --> 03:29.720
And then what we'll do here is we'll choose x, w, w form, u, r, l encoded.

100
03:29.720 --> 03:33.410
And the key here, and this is why we're doing it this way, is we're actually
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

100
03:29.720 --> 03:33.410
And the key here, and this is why we're doing it this way, is we're actually

101
03:33.410 --> 03:34.720
going to specify

102
03:34.720 --> 03:37.720
j_user_name, remember, j have a username, j have a password.

103
03:37.720 --> 03:40.720
And the corresponding value will be definite user.

104
03:40.720 --> 03:44.720
And again, we're going to have j_password.

105
03:44.720 --> 03:46.720
And again, let's just grab that password value.

106
03:46.720 --> 03:48.720
This is one right here.

107
03:48.720 --> 03:50.720
And just paste this in.

108
03:50.720 --> 03:53.720
So now we have the actual end point to get the token.

109
03:53.720 --> 03:55.720
We'll specify the post request.

110
03:55.720 --> 03:57.720
We have our headers specifying.

111
03:57.720 --> 04:02.720
We're going to be sending application x, w, w form, u, r, l encoded data.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

111
03:57.720 --> 04:02.720
We're going to be sending application x, w, w form, u, r, l encoded data.

112
04:02.720 --> 04:06.720
And in the body, we have the j_user_name and j password for authentication.

113
04:06.720 --> 04:10.720
If we send this off right here, we get the response of 200.

114
04:10.720 --> 04:12.720
This indicates a good sign.

115
04:12.720 --> 04:16.410
However, we don't actually see anything in the output unless we go to the

116
04:16.410 --> 04:17.720
headers right here.

117
04:17.720 --> 04:21.760
And if we scroll up a little bit, we're actually going to see this option right

118
04:21.760 --> 04:22.720
here, the set

119
04:22.720 --> 04:23.720
cookie, see this?

120
04:23.720 --> 04:26.720
And the actual value here is the j session ID.

121
04:26.720 --> 04:32.720
See from this point here of the equal sign, all the way to the first semicolon.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

121
04:26.720 --> 04:32.720
See from this point here of the equal sign, all the way to the first semicolon.

122
04:32.720 --> 04:35.720
This here, this is the actual cookie that I want to be storing.

123
04:35.720 --> 04:39.440
Now the way Postman is going to handle this is that it's actually going to save

124
04:39.440 --> 04:39.720
this session here.

125
04:39.720 --> 04:45.370
So in fact, if I go and choose to go to my collections, choose new, and the new

126
04:45.370 --> 04:45.720
HTTP request,

127
04:45.720 --> 04:50.330
if I go to cookies, you're going to notice that we actually do have the session

128
04:50.330 --> 04:50.720
, the j session

129
04:50.720 --> 04:52.720
ID should I say stored right here.

130
04:52.720 --> 04:55.720
All right, so now we have this j session ID cookie.

131
04:55.720 --> 05:00.140
With us now available to us and stored within Postman, what we want to do is to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

131
04:55.720 --> 05:00.140
With us now available to us and stored within Postman, what we want to do is to

132
05:00.140 --> 05:00.720
use this

133
05:00.720 --> 05:02.720
to get our CSRF token.

134
05:02.720 --> 05:08.000
This is basically a token to prevent something known as cross-side request for

135
05:08.000 --> 05:08.720
geries, which

136
05:08.720 --> 05:12.720
is once again just a simple security measure to prevent particular attacks.

137
05:12.720 --> 05:17.270
So as per the documentation as we saw, we just sent a request to j security

138
05:17.270 --> 05:18.720
check, the port request

139
05:18.720 --> 05:21.720
that is, and that has returned this j session ID cookie.

140
05:21.720 --> 05:26.450
This has allowed us to authenticate, and now we're going to have to get this CS

141
05:26.450 --> 05:27.720
RF prevention token.

142
05:27.720 --> 05:33.050
Now it says the other way we do this is we target this particular URL, this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

142
05:27.720 --> 05:33.050
Now it says the other way we do this is we target this particular URL, this

143
05:33.050 --> 05:34.720
time with a get request,

144
05:34.720 --> 05:37.720
and we're going to have to pass in the j session ID cookie.

145
05:37.720 --> 05:39.720
So let's go and do this then.

146
05:39.720 --> 05:42.720
Let's grab the actual endpoints, we're going to target.

147
05:42.720 --> 05:46.720
Let's paste this in, and again let's get the devnet sandbox appended in.

148
05:46.720 --> 05:48.720
Remember this time it's going to be a get request.

149
05:48.720 --> 05:53.470
The j session ID is stored already within the cookies automatically with Post

150
05:53.470 --> 05:53.720
man, so we don't

151
05:53.720 --> 05:55.720
have to do that configuration manually.

152
05:55.720 --> 05:59.720
We're going to specify the content type, it's going to be application JSON.

153
05:59.720 --> 06:03.720
Let's go to the headers, we'll say content type as application JSON.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

153
05:59.720 --> 06:03.720
Let's go to the headers, we'll say content type as application JSON.

154
06:03.720 --> 06:07.890
So now we have a new endpoint utilizing the get method with the cookie

155
06:07.890 --> 06:08.720
configured as a

156
06:08.720 --> 06:13.720
it's now available, and we have our headers of content type application JSON.

157
06:13.720 --> 06:18.520
If we now send this off, we once again get a 200 status code, and this time we

158
06:18.520 --> 06:18.720
're actually

159
06:18.720 --> 06:23.720
getting the CSRF token right here or the CSRF prevention token.

160
06:23.720 --> 06:27.540
So this is the one we want to be using to actually make all further requests to

161
06:27.540 --> 06:28.720
the API.

162
06:28.720 --> 06:32.710
So again if we go back to the documentation, if we go to the API reference
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

162
06:28.720 --> 06:32.710
So again if we go back to the documentation, if we go to the API reference

163
06:32.710 --> 06:33.720
right here,

164
06:33.720 --> 06:38.030
so we can see straight away the servers are forward slash data service, and

165
06:38.030 --> 06:38.720
then if we

166
06:38.720 --> 06:41.720
scroll on down we can see all of these additional options we can use.

167
06:41.720 --> 06:45.470
If you want to get particular admin information, here are the endpoints we can

168
06:45.470 --> 06:46.720
use, scrolling

169
06:46.720 --> 06:49.780
on down, we can get alarm details for monitoring, and we have a ton more

170
06:49.780 --> 06:50.720
available options as

171
06:50.720 --> 06:51.720
you can see right here.

172
06:51.720 --> 06:56.130
So say for example this option here, device, this will list all devices within

173
06:56.130 --> 06:56.720
SD1.

174
06:56.720 --> 06:57.720
So what is the path going to be?

175
06:57.720 --> 07:00.720
Well it's going to be as we saw at the very top.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

175
06:57.720 --> 07:00.720
Well it's going to be as we saw at the very top.

176
07:00.720 --> 07:05.720
So if we go back, remember we have our token now, let's create a new request,

177
07:05.720 --> 07:08.720
let's pass

178
07:08.720 --> 07:13.720
in this URL of data service and device, it will be a get request we're sending,

179
07:13.720 --> 07:13.720
and within

180
07:13.720 --> 07:19.010
the headers we're going to say x, xsRF, hyphen token, and then I'll paste in

181
07:19.010 --> 07:19.720
the value of

182
07:19.720 --> 07:24.050
that token I just got, remembering in the cookies we still have our j session

183
07:24.050 --> 07:24.720
ID stored

184
07:24.720 --> 07:25.720
right here.

185
07:25.720 --> 07:30.060
So if I now send this get request to this end point, specify my headers with
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

185
07:25.720 --> 07:30.060
So if I now send this get request to this end point, specify my headers with

186
07:30.060 --> 07:30.720
the token

187
07:30.720 --> 07:35.130
that we have now got, if I hit send here, give it a moment, what we're actually

188
07:35.130 --> 07:35.720
seeing

189
07:35.720 --> 07:39.790
here is once again a 200 status code and we're now getting a list of all

190
07:39.790 --> 07:40.720
devices within

191
07:40.720 --> 07:41.720
SD1.

192
07:41.720 --> 07:43.720
So that's right here, all this information.

193
07:43.720 --> 07:47.990
Now no doubt if this is the first time working with the SD1 API, this can be a

194
07:47.990 --> 07:48.720
little bit confusing.

195
07:48.720 --> 07:53.030
As a recap, the first time we're going to have to do is to login via our

196
07:53.030 --> 07:53.720
username and

197
07:53.720 --> 07:58.800
our password, the way we do this is by specifying our j username and our j

198
07:58.800 --> 08:00.720
password, the information
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

198
07:58.800 --> 08:00.720
password, the information

199
08:00.720 --> 08:06.240
is going to be sent x www.form URL encoded, and once we send this off, this is

200
08:06.240 --> 08:06.720
going to

201
08:06.720 --> 08:11.350
give us our j session ID, which is pretty much our little cookie, we then use

202
08:11.350 --> 08:12.720
this particular

203
08:12.720 --> 08:17.380
cookie to get our CSRF token, and then we use this token going forward to make

204
08:17.380 --> 08:17.720
all of

205
08:17.720 --> 08:20.720
our requests to the available end points within SD1.
