1
00:00:00,240 --> 00:00:06,870
In this video we are going to enter test rest API and lambda function with incoming rest API event JSON

2
00:00:06,870 --> 00:00:09,020
object to perform business logic.

3
00:00:09,030 --> 00:00:10,650
So let's get started.

4
00:00:11,010 --> 00:00:16,380
For that purpose, I have created a separate folder in our juju code project.

5
00:00:16,380 --> 00:00:22,230
So these are the requests that we are going to send using to Postman and these are the response from

6
00:00:22,230 --> 00:00:23,850
coming from the lambda functions.

7
00:00:23,850 --> 00:00:27,510
So let's get started to get these URLs.

8
00:00:27,510 --> 00:00:34,590
Please open the console, go to API, get a product API, go to states under the prod, select the get

9
00:00:34,590 --> 00:00:36,960
method and copy from this emotional.

10
00:00:37,410 --> 00:00:45,630
So we are pasting these with the postman open any request and paste in here we are going to send get

11
00:00:45,630 --> 00:00:48,510
request, get product, click the send button.

12
00:00:49,410 --> 00:00:51,990
So as you can see that the message is response.

13
00:00:51,990 --> 00:00:58,380
In here there is a message successfully finished operation so the body is processing get all products.

14
00:00:58,380 --> 00:01:01,230
So if you look at the operation, you can see that there is an undefined.

15
00:01:01,230 --> 00:01:04,110
So that means there's an error in our code.

16
00:01:04,110 --> 00:01:07,980
So if you open the code, please open the indexes.

17
00:01:07,980 --> 00:01:14,250
You can see that instead of we are passing the method, we are passing the raw k, it is leaving from

18
00:01:14,250 --> 00:01:15,480
the http api.

19
00:01:15,510 --> 00:01:21,540
So that's why please update this method for everywhere in your indexes.

20
00:01:21,540 --> 00:01:29,040
Copy these codes and go to the lambda and update our codes in here.

21
00:01:29,340 --> 00:01:34,470
Let me copy and paste all and make sure that you are returning the method.

22
00:01:34,500 --> 00:01:36,540
Deploy the lambda function.

23
00:01:36,960 --> 00:01:41,190
Okay, now come back to postman and send the request again.

24
00:01:41,190 --> 00:01:45,810
So this time we can see that we are successful to get request in here.

25
00:01:45,810 --> 00:01:50,550
So the message is correct and successfully response back to lambda function.

26
00:01:50,550 --> 00:01:52,710
So I'm continuing the other request.

27
00:01:52,710 --> 00:01:56,700
So other request is get product by ID for that purpose.

28
00:01:56,700 --> 00:02:04,370
Copy this URL, create a new request and come here and in here I'm writing a random product ID and send

29
00:02:04,380 --> 00:02:10,620
request and verify that we are sending the HTTP get method and we are proceeding get product ID with

30
00:02:10,620 --> 00:02:12,210
this ID information.

31
00:02:12,210 --> 00:02:13,140
So very good.

32
00:02:13,140 --> 00:02:16,650
So another request is post request.

33
00:02:16,650 --> 00:02:20,940
So I'm going to copy your app from here and paste in here.

34
00:02:20,970 --> 00:02:28,320
This will be the post product change the estimated as a post and this time I am going to set the body

35
00:02:28,320 --> 00:02:35,490
raw JSON and you can get the body information from our application command text window.

36
00:02:35,490 --> 00:02:39,210
I'm going to copy payload in here and paste in here.

37
00:02:39,210 --> 00:02:44,160
So basically we will create a new product with a HTTP post request and click the send button.

38
00:02:44,160 --> 00:02:49,560
So we have verified that we successfully finish the post operation and these are the payloads that we

39
00:02:49,560 --> 00:02:53,460
need to pass these payload with the JSON methods.

40
00:02:53,460 --> 00:02:54,180
Okay.

41
00:02:54,210 --> 00:03:00,000
We successfully get response from the post method and the last method is the HTTP delayed.

42
00:03:00,000 --> 00:03:01,230
So delayed by ID.

43
00:03:01,230 --> 00:03:01,960
So that's why I am.

44
00:03:01,980 --> 00:03:07,590
Copy this url and come here, paste here and change http method as a delete.

45
00:03:07,590 --> 00:03:09,900
And now I am going to delete this product.

46
00:03:09,900 --> 00:03:13,320
ID send a method and get back to response.

47
00:03:13,320 --> 00:03:15,540
The message is successfully finished.

48
00:03:15,540 --> 00:03:20,670
Delete operation and processing it by product ID, which product ID is in here.

49
00:03:20,970 --> 00:03:28,680
So as you can see that we have successfully test our rest API and lambda functions and finish the hands

50
00:03:28,680 --> 00:03:33,450
on lab, which is the building code microservices with rest API and lambda functions.
