WEBVTT

1
00:00.000 --> 00:02.800
Alright friends, so let's walk through the solution name.

2
00:02.800 --> 00:05.680
So the first thing I will do is to load up Postman,

3
00:05.680 --> 00:07.600
and I will go and create a new request, okay?

4
00:07.600 --> 00:08.360
So here we go.

5
00:08.360 --> 00:10.200
So the very first thing that I'm going to have to do

6
00:10.200 --> 00:12.800
is I'm going to have to log in, and I will do this

7
00:12.800 --> 00:15.680
by going to the DevNet Sandbox address.

8
00:15.680 --> 00:16.960
And the actual end point is going to be

9
00:16.960 --> 00:20.840
J_security_check as we saw within the skill.

10
00:20.840 --> 00:23.760
Now remember, the actual method I'm going to have to use here

11
00:23.760 --> 00:25.600
is going to be a post request.

12
00:25.600 --> 00:28.520
And at this point here, I'm going to have to go to the body,

13
00:28.520 --> 00:32.560
make sure it's x www.form_urlencoded.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

13
00:28.520 --> 00:32.560
make sure it's x www.form_urlencoded.

14
00:32.560 --> 00:36.800
And the key here is going to be J_userName.

15
00:36.800 --> 00:39.880
And the value right now is going to be DevNet user.

16
00:39.880 --> 00:42.600
And the password will be J_password.

17
00:42.600 --> 00:44.920
And as we saw within the skill, the current password,

18
00:44.920 --> 00:47.080
as I recorded, is this right here.

19
00:47.080 --> 00:49.240
Now I'm going to go to the headers tab.

20
00:49.240 --> 00:51.720
I'll say the content type, and I'll give it the value

21
00:51.720 --> 00:56.400
of application, and I'll say x www.form_urlencoded.

22
00:56.400 --> 00:59.160
And now I will send off this particular request.

23
00:59.160 --> 01:03.280
So now I get this OK as we see within the headers down here.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

23
00:59.160 --> 01:03.280
So now I get this OK as we see within the headers down here.

24
01:03.280 --> 01:04.520
I'm going to have the cookie set.

25
01:04.520 --> 01:07.160
Because of this, like I say, when it comes to creating

26
01:07.160 --> 01:09.120
a new request, as we can do right here,

27
01:09.120 --> 01:11.040
the cookies should be stored automatically

28
01:11.040 --> 01:13.040
via postman as we can see right here.

29
01:13.040 --> 01:16.360
So if that's now done, we want to now get the CSRF token.

30
01:16.360 --> 01:18.800
Now this time, the end point is going to be

31
01:18.800 --> 01:21.200
forward slash data service, forward slash client,

32
01:21.200 --> 01:23.480
forward slash token as we saw within the skill.

33
01:23.480 --> 01:25.760
The method this time is going to be a get request,

34
01:25.760 --> 01:27.040
not a post request.

35
01:27.040 --> 01:29.080
As we know, the cookie will automatically be set

36
01:29.080 --> 01:31.160
via postman, so we don't have to worry about this.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

36
01:29.080 --> 01:31.160
via postman, so we don't have to worry about this.

37
01:31.160 --> 01:33.720
So if I just hit sends, I'm going to get back

38
01:33.720 --> 01:36.280
this particular token, so I'll just copy this right here,

39
01:36.280 --> 01:38.240
and now I'll create my new request.

40
01:38.240 --> 01:39.680
Now remember for the actual request,

41
01:39.680 --> 01:42.160
the target endpoint is going to be data service,

42
01:42.160 --> 01:44.920
device, statistics, we want to consult a documentation

43
01:44.920 --> 01:47.600
to ensure we use the correct HTTP method.

44
01:47.600 --> 01:50.240
So the first thing I will do is put in this endpoint

45
01:50.240 --> 01:53.480
of device statistics, or device stats, should I say.

46
01:53.480 --> 01:55.240
So let's go to the documentation,

47
01:55.240 --> 01:56.360
like this link here.

48
01:56.360 --> 01:59.360
If we go to the API reference, as we saw within the skill,

49
01:59.360 --> 02:01.240
we're going to say forward slash data service.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

49
01:59.360 --> 02:01.240
we're going to say forward slash data service.

50
02:01.240 --> 02:03.080
We already know this, but what we're looking for

51
02:03.080 --> 02:05.240
is if I just search for forward slash device,

52
02:05.240 --> 02:06.760
here we have it right here, this is going to be

53
02:06.760 --> 02:08.640
a get request we have to send.

54
02:08.640 --> 02:10.160
So let's go back to postman.

55
02:10.160 --> 02:12.880
For this particular request, let's go to our headers.

56
02:12.880 --> 02:17.520
What we're going to say here is X, XSRF, token,

57
02:17.520 --> 02:19.440
and then I'm going to paste in that token value

58
02:19.440 --> 02:20.360
we just got.

59
02:20.360 --> 02:22.680
As we know, the cookies should still already be saved

60
02:22.680 --> 02:25.200
within postman, makes things a little bit easier for us.

61
02:25.200 --> 02:28.960
And if I now hit send, we actually do get a successful

62
02:28.960 --> 02:31.080
request for device statistics.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

62
02:28.960 --> 02:31.080
request for device statistics.

63
02:31.080 --> 02:32.120
Okay, moving on.

64
02:32.120 --> 02:33.680
So the next thing we're going to do is to connect

65
02:33.680 --> 02:36.520
to the DevNet Always on Sandbox for Catalyst Center

66
02:36.520 --> 02:40.080
and return information about sites within Catalyst Center.

67
02:40.080 --> 02:42.520
To do this, we're going to have to consult the documentation.

68
02:42.520 --> 02:45.120
So the first thing we'll do is create a new request.

69
02:45.120 --> 02:45.960
Here we go.

70
02:45.960 --> 02:47.320
Remember, the first time we're going to have to do

71
02:47.320 --> 02:48.240
is to get that token.

72
02:48.240 --> 02:51.240
So what I will do is type in the address of the DevNet

73
02:51.240 --> 02:53.760
Sandbox for DNA Center and then target the

74
02:53.760 --> 02:55.320
auth token endpoint.

75
02:55.320 --> 02:58.160
We're going to then set the authorization to be

76
02:58.160 --> 02:59.600
basic authentication.

77
02:59.600 --> 03:01.480
And the username right now is DevNet user
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

77
02:59.600 --> 03:01.480
And the username right now is DevNet user

78
03:01.480 --> 03:04.400
and the password is Cisco 123 exclamation mark.

79
03:04.400 --> 03:05.560
As we can see right here.

80
03:05.560 --> 03:07.200
Let's go to the headers.

81
03:07.200 --> 03:08.760
We'll see the content type.

82
03:08.760 --> 03:11.840
It's going to be application forward slash JSON.

83
03:11.840 --> 03:13.560
And we're going to make sure that this is a

84
03:13.560 --> 03:14.880
post request, remember.

85
03:14.880 --> 03:17.560
So if we click send, now we get our token.

86
03:17.560 --> 03:19.320
So let's copy all of this.

87
03:19.320 --> 03:21.480
Now, before we go any further, we're going to have to

88
03:21.480 --> 03:24.360
target the sites within Catalyst Center.

89
03:24.360 --> 03:26.280
To do this, we're going to consult the documentation.

90
03:26.280 --> 03:27.480
So let's check this out.

91
03:27.480 --> 03:30.600
So if we search for Catalyst Centers Rest API Docs,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

91
03:27.480 --> 03:30.600
So if we search for Catalyst Centers Rest API Docs,

92
03:30.600 --> 03:32.240
let's go and click this link here.

93
03:32.240 --> 03:34.400
Now, then the left hand side, we're going to try to find

94
03:34.400 --> 03:35.960
information relating to sites.

95
03:35.960 --> 03:37.160
And we can see this option here.

96
03:37.160 --> 03:38.280
So let's click this.

97
03:38.280 --> 03:40.800
And now as we know, we can go and look at the end points

98
03:40.800 --> 03:42.160
and methods used.

99
03:42.160 --> 03:43.800
So we have these particular options.

100
03:43.800 --> 03:46.520
So any combination of these is going to be quite just fine.

101
03:46.520 --> 03:49.120
In my case here, let's keep it quite simple.

102
03:49.120 --> 03:51.440
Let's just get information by targeting this.

103
03:51.440 --> 03:54.480
This particular end point with the get request.

104
03:54.480 --> 03:56.440
So we've got a new request once again.

105
03:56.440 --> 03:57.760
There is a DevNet URL.

106
03:57.760 --> 04:00.240
And let's just add on what we got from the documentation.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

106
03:57.760 --> 04:00.240
And let's just add on what we got from the documentation.

107
04:00.240 --> 04:03.160
Just copy you and make sure we set it to a get request,

108
04:03.160 --> 04:04.880
which is what we can see right here.

109
04:04.880 --> 04:07.120
Now in the headers here, remember what we're going to

110
04:07.120 --> 04:07.960
have to specify.

111
04:07.960 --> 04:11.680
We're going to say X of token.

112
04:11.680 --> 04:15.160
And then paste in the value of this token right here.

113
04:15.160 --> 04:16.720
So paste you in.

114
04:16.720 --> 04:18.800
Now, if this is now done, I should be able to send off

115
04:18.800 --> 04:19.640
the request.

116
04:19.640 --> 04:23.040
And as we can see here, we get the 200 response coming back

117
04:23.040 --> 04:23.960
to us right there.

118
04:23.960 --> 04:27.160
Now very briefly, if you wanted to do this via Python,

119
04:27.160 --> 04:28.680
well, what you could have done is actually

120
04:28.680 --> 04:30.240
kind of cheated a little bit.
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

120
04:28.680 --> 04:30.240
kind of cheated a little bit.

121
04:30.240 --> 04:32.480
And if we just reuse the same scripts that we had within

122
04:32.480 --> 04:35.120
the scale, but make slight modifications, let's go in here.

123
04:35.120 --> 04:37.920
So say for example, this one for DNA sensor,

124
04:37.920 --> 04:39.920
we go through the same process, provide the username

125
04:39.920 --> 04:43.000
password with basic authentication, get our token,

126
04:43.000 --> 04:46.600
and then pass in the token to the header of X of token.

127
04:46.600 --> 04:49.760
Only difference is that the end point here is going to change.

128
04:49.760 --> 04:52.480
So if I just change this here to the information that we got

129
04:52.480 --> 04:55.320
right there, and just delete this portion here and just say

130
04:55.320 --> 04:56.760
print the result.

131
04:56.760 --> 05:01.080
If I save this and I run the script, as we can see right here,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

131
04:56.760 --> 05:01.080
If I save this and I run the script, as we can see right here,

132
05:01.080 --> 05:03.160
we do get a valid response.

133
05:03.160 --> 05:06.520
Similarly, if I go back and modify my SD1 script,

134
05:06.520 --> 05:08.320
let me get copy of this one here.

135
05:08.320 --> 05:11.160
Same thing we saw before, we get the authentication cookie,

136
05:11.160 --> 05:14.240
we get this ESRF token, pass in with this header.

137
05:14.240 --> 05:16.200
The only difference here is we're going to modify this

138
05:16.200 --> 05:18.480
particular end point to be stats.

139
05:18.480 --> 05:23.480
So save this, Python 3, script 3, top py,

140
05:23.480 --> 05:26.600
and as we can see, we get a response.

141
05:26.600 --> 05:29.480
So friends, that is us for our validation challenge.

142
05:29.480 --> 05:31.240
I hope it's been informative for you,
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

142
05:29.480 --> 05:31.240
I hope it's been informative for you,

143
05:31.240 --> 05:33.080
and I'd like to thank you for viewing.
