WEBVTT

1
00:00.000 --> 00:04.320
Alright friends, so let's go and utilize one of the most popular tools for

2
00:04.320 --> 00:04.880
working with

3
00:04.880 --> 00:09.460
REST APIs and this is something known as Postman. So if I just set it for Post

4
00:09.460 --> 00:10.880
man API and let's

5
00:10.880 --> 00:15.930
click this top link here, if I go up to products and I choose Download Postman,

6
00:15.930 --> 00:16.160
pretty much what

7
00:16.160 --> 00:19.350
it's going to do is going to detect that I'm on a Macbook so it's going to give

8
00:19.350 --> 00:20.080
me the option

9
00:20.080 --> 00:24.560
to install for a Mac Apple chip or a Mac Intel chip but if you happen to be on

10
00:24.560 --> 00:26.320
Linux or on Windows

11
00:26.320 --> 00:30.720
you will see a similar type icon. Quite simply just click the one that resolves
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

11
00:26.320 --> 00:30.720
you will see a similar type icon. Quite simply just click the one that resolves

12
00:30.720 --> 00:31.520
to your platform

13
00:31.520 --> 00:35.010
and in my case here I will choose the Apple chip okay. So the download begins

14
00:35.010 --> 00:35.760
let's give this

15
00:35.760 --> 00:39.370
a moment to complete. So once I have opened this Postman is prompting me to

16
00:39.370 --> 00:40.480
create an account via

17
00:40.480 --> 00:44.540
my web browser if I just click to open this manually. As we can see here I have

18
00:44.540 --> 00:45.840
the option to create a

19
00:45.840 --> 00:49.580
free account or sign up with Google and in this case here I will use my Google

20
00:49.580 --> 00:50.560
account and all

21
00:50.560 --> 00:53.380
it's going to do is going to ask you to enter in some questions so I'll just

22
00:53.380 --> 00:55.280
say my name is John McGee

23
00:55.760 --> 00:59.910
what is your role, let's just say other, let's just say Trainer and choose

24
00:59.910 --> 01:01.520
Continue. All right so now I'm
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

24
00:59.910 --> 01:01.520
Continue. All right so now I'm

25
01:01.520 --> 01:05.940
here in Postman what I want to do is I want to begin making some requests. So

26
01:05.940 --> 01:06.880
this is what I will use

27
01:06.880 --> 01:10.910
as my client to make the request. What I want to do now is to have a server to

28
01:10.910 --> 01:12.000
talk to. If you search

29
01:12.000 --> 01:16.320
for Go Rest API let's go down here click on this link for this one and

30
01:16.320 --> 01:17.840
essentially this is just a

31
01:17.840 --> 01:22.320
website used for testing Reist API's okay. So we see some resources such as

32
01:22.320 --> 01:23.680
this endpoint here. This

33
01:23.680 --> 01:27.770
is how we can get information on the users that are stored in this particular

34
01:27.770 --> 01:28.960
server whereas if we

35
01:28.960 --> 01:32.840
want to read Post we can use this particular endpoint same thing here for
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

35
01:28.960 --> 01:32.840
want to read Post we can use this particular endpoint same thing here for

36
01:32.840 --> 01:34.240
comments so this is exactly

37
01:34.240 --> 01:39.070
what we talked about before particular URLs correlating to particular resources

38
01:39.070 --> 01:40.320
on the servers. So right

39
01:40.320 --> 01:44.610
now if I scroll on down what it actually says here is that if you want to make

40
01:44.610 --> 01:45.840
particular requests

41
01:45.840 --> 01:49.980
such as a put request or a post request or a delete request or a patch request

42
01:49.980 --> 01:50.400
basically any

43
01:50.400 --> 01:54.560
type of modifying behavior you need to have an access token which has to be

44
01:54.560 --> 01:56.160
passed in your authorization

45
01:56.160 --> 02:00.270
header. So just to make a simple get request we actually do not have to have
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

45
01:56.160 --> 02:00.270
header. So just to make a simple get request we actually do not have to have

46
02:00.270 --> 02:01.760
any type of authentication.

47
02:01.760 --> 02:06.290
So let's go and see how we can do this then what I will do here is I will copy

48
02:06.290 --> 02:07.440
this particular resource

49
02:07.440 --> 02:11.390
here okay so grab you let's go to Postman and what I will do is I'll choose

50
02:11.390 --> 02:12.960
this option to send an

51
02:12.960 --> 02:17.530
API request. So inside here I can specify the method I want I can have a get a

52
02:17.530 --> 02:18.640
post a put a patch

53
02:18.640 --> 02:23.280
so on so forth. Now I just want to retrieve information I you read data so we

54
02:23.280 --> 02:24.800
know the HTTP method

55
02:24.800 --> 02:28.920
we use as a get request and now we just specify the resource we want to target

56
02:28.920 --> 02:30.080
so let me just paste
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

56
02:28.920 --> 02:30.080
so let me just paste

57
02:30.080 --> 02:34.420
this in right here. Now we have our headers at the moment let's go and grab and

58
02:34.420 --> 02:35.360
accept header okay

59
02:35.360 --> 02:39.920
to specify what type of data we want so let's say accept and the type I'm going

60
02:39.920 --> 02:40.640
to say is

61
02:40.640 --> 02:45.620
application forward slash JSON okay now watch what happens if I just choose

62
02:45.620 --> 02:46.960
send here give a moment

63
02:46.960 --> 02:51.280
we send a request and look at this we're getting back a 200 okay response so we

64
02:51.280 --> 02:52.320
recall straight away

65
02:52.320 --> 02:56.860
this two tells us we have a success and a 200 like I say is just an okay

66
02:56.860 --> 02:58.800
message as we see right here

67
02:58.800 --> 03:02.690
nothing new was created but a request was successful. Now if I just go and
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

67
02:58.800 --> 03:02.690
nothing new was created but a request was successful. Now if I just go and

68
03:02.690 --> 03:04.080
scroll on down here in fact

69
03:04.080 --> 03:08.030
let me just pull us up a little bit grab you look at this right here we have

70
03:08.030 --> 03:09.440
all of this data relating

71
03:09.440 --> 03:13.280
to all of the users on this particular server and because we requested in our

72
03:13.280 --> 03:14.240
headers that we wanted

73
03:14.240 --> 03:18.740
JSON data back look at what we're actually seeing here see all this all of this

74
03:18.740 --> 03:19.280
is JSON

75
03:19.280 --> 03:23.890
so let's say we wanted to get a different type of data say for example we want

76
03:23.890 --> 03:24.960
to get the posts

77
03:24.960 --> 03:29.880
let's grab you and all we do is modify the endpoint mortality right here and if

78
03:29.880 --> 03:30.720
we just send off
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

78
03:29.880 --> 03:30.720
we just send off

79
03:30.720 --> 03:35.490
our request look at this right here completely different data we see the ID of

80
03:35.490 --> 03:36.640
the post the user

81
03:36.640 --> 03:40.080
ID pretty much who actually posted it the title as well as the body now the

82
03:40.080 --> 03:40.960
actual data here

83
03:40.960 --> 03:45.440
that's all fake data is just for testing so the content is not exactly so now

84
03:45.440 --> 03:46.080
like you say if you

85
03:46.080 --> 03:50.360
want to maybe create a new user via a post request as we see right here I'm

86
03:50.360 --> 03:52.000
going to have to create my

87
03:52.000 --> 03:55.920
own tokens let me get an access token here okay now all I will do is I will log

88
03:55.920 --> 03:56.800
in via my google

89
03:56.800 --> 04:00.650
account now right here I can see my access token I'm going to blood this out so
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

89
03:56.800 --> 04:00.650
account now right here I can see my access token I'm going to blood this out so

90
04:00.650 --> 04:01.600
you can actually read

91
04:01.600 --> 04:05.580
it so what I will now do is in my headers here I'm going to add the new header

92
04:05.580 --> 04:06.960
I'm going to add an

93
04:06.960 --> 04:10.380
authorization header okay and for the value I'm going to say it's the word

94
04:10.380 --> 04:11.120
better because it's

95
04:11.120 --> 04:15.060
going to be a better token and then after that I'll paste in the token itself

96
04:15.060 --> 04:15.600
now what I will do

97
04:15.600 --> 04:19.410
is if I go back to the documentation if I want to create a new user right here

98
04:19.410 --> 04:20.160
it says that I'm

99
04:20.160 --> 04:24.360
going to have to use this particular endpoint public v2 users which is

100
04:24.360 --> 04:25.840
basically the same one we

101
04:25.840 --> 04:29.440
saw when we use the get request so let's grab this again paste in this

102
04:29.440 --> 04:30.480
particular value
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

102
04:29.440 --> 04:30.480
particular value

103
04:30.480 --> 04:35.760
and I'm also going to add in a content type header okay and this time here I'll

104
04:35.760 --> 04:36.560
say I'm going to have

105
04:36.560 --> 04:40.640
application json I'll be sending over json data and inside the body here I will

106
04:40.640 --> 04:41.920
choose raw and now

107
04:41.920 --> 04:45.460
all I will do is add in the data that I'm going to add so let's have my color

108
04:45.460 --> 04:46.640
brace for my json

109
04:46.640 --> 04:51.440
object and I'll just say the name which is called as rest test let's have a

110
04:51.440 --> 04:53.280
colon so the email is

111
04:53.280 --> 04:59.650
rest test at example dot com I'll say the gender as female and the status is

112
04:59.650 --> 05:01.360
going to be active
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

112
04:59.650 --> 05:01.360
going to be active

113
05:01.360 --> 05:06.120
and if I change this to a post request and then I choose to send this off we

114
05:06.120 --> 05:06.480
can actually

115
05:06.480 --> 05:11.350
see here we get a 201 a created response pretty much we've now created a new

116
05:11.350 --> 05:12.320
resource within this

117
05:12.320 --> 05:15.630
particular server and if I try to resend a request we can see here we're

118
05:15.630 --> 05:16.960
actually now getting a

119
05:16.960 --> 05:21.570
client error as denoted via the four status codes and the response is actually

120
05:21.570 --> 05:22.800
telling us hey this

121
05:22.800 --> 05:26.780
email has already been taken i.e the email that we use in this particular body

122
05:26.780 --> 05:28.160
we can no longer use

123
05:28.160 --> 05:32.550
it so what I could do is I could go and modify this one more time to say john
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

123
05:28.160 --> 05:32.550
it so what I could do is I could go and modify this one more time to say john

124
05:32.550 --> 05:33.920
blah blah blah

125
05:33.920 --> 05:37.600
I've been some blah blah blah let's change this maybe to mail now we should not

126
05:37.600 --> 05:38.560
have a clash if I

127
05:38.560 --> 05:43.020
send this one off once again we've created a new entity within the server

128
05:43.020 --> 05:44.240
itself so this is how we

129
05:44.240 --> 05:49.230
can utilize postman to send requests to arrest APIs with that now done let's

130
05:49.230 --> 05:50.240
devalade what we've

131
05:50.240 --> 05:51.600
learned within this skill
