1
00:00:00,660 --> 00:00:03,000
Instructor: So, let's use Beeceptor

2
00:00:03,000 --> 00:00:07,260
and see how we can use it to simulate REST API.

3
00:00:07,260 --> 00:00:12,247
So first, head to this URL, https://beeceptor.com.

4
00:00:13,255 --> 00:00:17,700
So, this is Beeceptor's homepage.

5
00:00:17,700 --> 00:00:19,500
You see here a short description

6
00:00:19,500 --> 00:00:24,000
of what Beeceptor does and a large text box.

7
00:00:24,000 --> 00:00:27,330
In this text box, you are going to choose the domain

8
00:00:27,330 --> 00:00:30,540
that you are going to use to simulate the REST API.

9
00:00:30,540 --> 00:00:33,090
It can be any name you would like,

10
00:00:33,090 --> 00:00:36,360
so just pick a name and write it here.

11
00:00:36,360 --> 00:00:40,057
I'll use here, apicourse and create endpoint.

12
00:00:46,260 --> 00:00:48,300
Now you see this page.

13
00:00:48,300 --> 00:00:49,133
In this page.

14
00:00:49,133 --> 00:00:53,930
What you see, is the full URL of the server of the domain.

15
00:00:55,650 --> 00:00:59,130
Your API will be residing, copy this URL,

16
00:00:59,130 --> 00:01:00,933
we will use it later in this course.

17
00:01:02,310 --> 00:01:06,420
And now, what we would like to do now is create

18
00:01:06,420 --> 00:01:10,650
a test API to make sure everything is working fine.

19
00:01:10,650 --> 00:01:13,890
Now REST API mocking in receptor

20
00:01:13,890 --> 00:01:16,710
is defined using the mocking rules.

21
00:01:16,710 --> 00:01:18,390
You can see it up here.

22
00:01:18,390 --> 00:01:23,390
So, let's click mocking rules and create new rule.

23
00:01:24,600 --> 00:01:27,900
And this is where things get really interesting.

24
00:01:27,900 --> 00:01:31,590
So, what we do in this page is defining what is

25
00:01:31,590 --> 00:01:34,560
the REST API that we want to mock?

26
00:01:34,560 --> 00:01:37,140
Including its address, its verb,

27
00:01:37,140 --> 00:01:40,620
its headers, its response, and the body.

28
00:01:40,620 --> 00:01:45,570
So, let's define a REST API endpoint and see what happens.

29
00:01:45,570 --> 00:01:48,840
So, first we are going to choose the method.

30
00:01:48,840 --> 00:01:51,000
If you click this and opens the list,

31
00:01:51,000 --> 00:01:53,520
then you can see here all the HTP verbs

32
00:01:53,520 --> 00:01:55,830
we talked about, including some more

33
00:01:55,830 --> 00:01:57,030
that we didn't talk about.

34
00:01:57,030 --> 00:01:58,803
And we will go with GET.

35
00:01:59,760 --> 00:02:04,140
Here, we are going to write the URL of the REST API.

36
00:02:04,140 --> 00:02:09,139
So, let's call it api/test.

37
00:02:10,620 --> 00:02:13,470
In this text box, we pick the status code

38
00:02:13,470 --> 00:02:15,720
we want the API to return.

39
00:02:15,720 --> 00:02:20,100
In this case, we will leave it as it is 200 meaning, okay.

40
00:02:20,100 --> 00:02:22,740
And here, is the response body

41
00:02:22,740 --> 00:02:24,960
or the contents of the response.

42
00:02:24,960 --> 00:02:26,430
So in this text box,

43
00:02:26,430 --> 00:02:29,130
we will define what will be the response

44
00:02:29,130 --> 00:02:33,150
we will get from Beeceptor when calling the API.

45
00:02:33,150 --> 00:02:37,800
So, let's just change this to success,

46
00:02:37,800 --> 00:02:42,800
so that our test is success and click save rule.

47
00:02:43,950 --> 00:02:47,700
So, this is our first REST API mocking

48
00:02:47,700 --> 00:02:49,350
and let's see if it works.

49
00:02:49,350 --> 00:02:51,820
Let's open another instance of the browser

50
00:02:52,950 --> 00:02:56,550
and paste here the URL we picked before,

51
00:02:56,550 --> 00:02:58,620
notice the domain name here.

52
00:02:58,620 --> 00:03:00,510
This is a domain name that we selected

53
00:03:00,510 --> 00:03:04,009
at the beginning when creating our account in Beeceptor.

54
00:03:04,009 --> 00:03:07,560
And then, we'll just write what is written here,

55
00:03:07,560 --> 00:03:10,620
the URL of our API.

56
00:03:10,620 --> 00:03:14,850
So, this will be api/test.

57
00:03:14,850 --> 00:03:19,830
Enter and you see here the body that we defined.

58
00:03:19,830 --> 00:03:23,100
So, it looks that everything is working just fine.

59
00:03:23,100 --> 00:03:25,830
We are going to use Beeceptor across this course

60
00:03:25,830 --> 00:03:26,970
and you will find out,

61
00:03:26,970 --> 00:03:29,580
it's very easy to use and very useful

62
00:03:29,580 --> 00:03:31,293
for learning REST API.

