1
00:00:00,780 --> 00:00:02,670
-: The next part of the URL

2
00:00:02,670 --> 00:00:06,120
and this is the first optional part of the URL

3
00:00:06,120 --> 00:00:07,830
is the ID parameter.

4
00:00:07,830 --> 00:00:11,130
Now, what is it actually the ID parameter?

5
00:00:11,130 --> 00:00:14,820
So when the URL deals with a specific entity

6
00:00:14,820 --> 00:00:17,640
then the next part is the ID

7
00:00:17,640 --> 00:00:19,710
of the entity that we are dealing with.

8
00:00:19,710 --> 00:00:23,220
Now, what do we mean by dealing with a specific entity?

9
00:00:23,220 --> 00:00:25,860
Well, there are some examples that we'll see later

10
00:00:25,860 --> 00:00:27,990
but the most simple one is

11
00:00:27,990 --> 00:00:31,710
that we want to get a specific entity.

12
00:00:31,710 --> 00:00:33,870
Not to perform a search in the database

13
00:00:33,870 --> 00:00:35,730
for a range of entities,

14
00:00:35,730 --> 00:00:38,599
but we actually want the server to bring us back

15
00:00:38,599 --> 00:00:42,780
a very specific entity which has a unique idea.

16
00:00:42,780 --> 00:00:46,260
And this is where the ID will come in the URL.

17
00:00:46,260 --> 00:00:48,000
So the ID is really part

18
00:00:48,000 --> 00:00:51,480
of the URL and it'll look something like this.

19
00:00:51,480 --> 00:00:55,200
So here we have the api, the version, the entity

20
00:00:55,200 --> 00:00:57,000
and the ID.

21
00:00:57,000 --> 00:01:01,470
So when exactly are we going to use this id?

22
00:01:01,470 --> 00:01:05,040
So the main use of the ID as we mentioned earlier

23
00:01:05,040 --> 00:01:09,420
is with GET when we want to retrieve a specific entity.

24
00:01:09,420 --> 00:01:12,480
But it is also used with PUT

25
00:01:12,480 --> 00:01:16,020
remember that PUT is used to update an entity.

26
00:01:16,020 --> 00:01:18,420
So when we are updating an entity

27
00:01:18,420 --> 00:01:22,620
we need to specify which entity we want to update.

28
00:01:22,620 --> 00:01:25,350
And for this, we will use the ID parameter.

29
00:01:25,350 --> 00:01:29,064
In addition ID parameter often used with the delete

30
00:01:29,064 --> 00:01:33,000
because when we need to delete a specific entity, we

31
00:01:33,000 --> 00:01:37,440
will specify the entity using the ID parameter in the URL.

32
00:01:37,440 --> 00:01:40,622
Now what you won't see in this list is the post

33
00:01:40,622 --> 00:01:45,390
because when adding a new entity, there is no ID for it.

34
00:01:45,390 --> 00:01:48,750
The ID will be usually set by the database.

35
00:01:48,750 --> 00:01:52,443
And when adding the entity, we still do not have its ID.

36
00:01:53,400 --> 00:01:57,573
Okay, so now let's add the ID to our URL.

37
00:01:59,310 --> 00:02:01,800
So here we are again in Receptor

38
00:02:01,800 --> 00:02:06,800
and all we need to do is simply add forward slash and an ID.

39
00:02:06,870 --> 00:02:10,560
In this case, I will use number 17.

40
00:02:10,560 --> 00:02:13,170
So we have a URL

41
00:02:13,170 --> 00:02:18,170
with the API version entity, and ID.

