1
00:00:00,360 --> 00:00:07,440
In this video, we are going to understand how a HTTP API triggers a lambda, even JSON object.

2
00:00:07,560 --> 00:00:13,050
And after that, we will develop our lambda function with incoming events to perform CRUD operations.

3
00:00:13,350 --> 00:00:16,380
In the last video we have test our API gateway.

4
00:00:16,410 --> 00:00:22,410
With this link you can see in here with this link we test and it is turned back to hello from Lambda,

5
00:00:22,500 --> 00:00:29,940
but this time we will test for all cases to understand incoming event json http API to the lambda function.

6
00:00:29,940 --> 00:00:33,570
We can see that we will get get by ID, post and delete.

7
00:00:33,570 --> 00:00:39,360
So we will collect these even JSON object one HTTP API go to a base lambda.

8
00:00:39,360 --> 00:00:43,990
And according to these events JSON object, we will develop our lambda function in the next videos.

9
00:00:44,010 --> 00:00:45,690
So let's get started.

10
00:00:45,840 --> 00:00:46,260
Okay.

11
00:00:46,260 --> 00:00:53,730
Now I'm going to send a HTTP, get post and delete methods one by one and see incoming events from HTTP

12
00:00:53,730 --> 00:00:55,320
API to a lambda.

13
00:00:55,410 --> 00:00:56,790
So let's get started.

14
00:00:56,790 --> 00:00:59,250
In order to do that, please open the postman.

15
00:00:59,250 --> 00:01:04,470
So we should get the API up from the API gateway.

16
00:01:04,620 --> 00:01:08,910
I'm going to copy from here and come the postman and paste here.

17
00:01:08,940 --> 00:01:11,640
Now this time I'm going to start with basics.

18
00:01:11,640 --> 00:01:15,060
As you can see that we are performing to get product section.

19
00:01:15,060 --> 00:01:22,080
So http get and we provide this product append to the our URL.

20
00:01:22,110 --> 00:01:25,020
Now click the send button and this will be triggered.

21
00:01:25,020 --> 00:01:28,380
The API gateway will turn back the header from lambda.

22
00:01:28,380 --> 00:01:30,480
So I'm going to check lambda.

23
00:01:31,270 --> 00:01:34,250
Walks for that purpose, please go to Lambda functions.

24
00:01:34,270 --> 00:01:35,680
Open the product function.

25
00:01:35,830 --> 00:01:39,040
Go to monitoring v logs in cloud logs.

26
00:01:39,040 --> 00:01:44,110
So now we will see how http api triggered to lambda function.

27
00:01:44,680 --> 00:01:52,570
And here you can see that I'm going to copy this JSON file and go to the Visual Studio code and I'm

28
00:01:52,570 --> 00:02:00,340
going to paste in here, even get JSON example and remove the first part and save this file.

29
00:02:00,340 --> 00:02:07,300
So as you can see that we sent get product and these get product exactly seems in the road K of the

30
00:02:07,330 --> 00:02:13,540
event JSON file which is selected from the API gateway and you can see also raw pet in here.

31
00:02:13,540 --> 00:02:16,240
So basically these are the important parameters.

32
00:02:16,240 --> 00:02:20,800
According to these parameters, we can identify incoming growth and HTTP method.

33
00:02:21,100 --> 00:02:24,250
So now let me send another request.

34
00:02:24,250 --> 00:02:26,260
We save these get method.

35
00:02:26,290 --> 00:02:29,230
Now I will continue with our example.

36
00:02:29,230 --> 00:02:34,990
You can see in here this time I'm going to send get product by ID request for that purpose.

37
00:02:34,990 --> 00:02:44,560
Let's open the postman and create a any request and copy the payload you are in here paste in here.

38
00:02:44,560 --> 00:02:52,030
This will be the http get but this time I'm going to add some appending the product ID for example we

39
00:02:52,030 --> 00:02:58,630
can add slash for and also I can add some queries things for example, category.

40
00:03:00,210 --> 00:03:01,500
A cool phone.

41
00:03:03,430 --> 00:03:08,950
So this is some advance get requests that including the product ID and query string.

42
00:03:08,950 --> 00:03:13,660
So lets click the send button and this will be returned back to us.

43
00:03:14,080 --> 00:03:19,450
The same message because this again the integrated lambda function and return back to the message.

44
00:03:19,450 --> 00:03:26,560
But this time we will understand how these events and object trigger to a lambda again for that purpose

45
00:03:26,560 --> 00:03:28,000
go to colored watch looks.

46
00:03:29,260 --> 00:03:30,250
Come here.

47
00:03:30,280 --> 00:03:36,280
Open the latest log stream for our product function and go to latest look.

48
00:03:36,370 --> 00:03:44,230
And if you copy this look and if you go to the we use the code this time I have created get by ID.

49
00:03:45,170 --> 00:03:48,950
Or to beginning and remove the first line and save this file.

50
00:03:49,100 --> 00:03:57,200
So as you can see that we have created get product by ID and we have important values that we can catch

51
00:03:57,200 --> 00:03:58,940
these into our lambda function.

52
00:03:58,940 --> 00:04:03,080
For example, see the rock and roll pet in this time.

53
00:04:03,080 --> 00:04:08,690
This is the get product by ID and raw pet is products like for the exact ID information.

54
00:04:08,870 --> 00:04:13,700
And also you can see that we have real quick listing parameters.

55
00:04:13,700 --> 00:04:18,380
If you scroll down, we have created parameters which is the category form.

56
00:04:18,560 --> 00:04:24,950
And if you scroll down we can see that we have pet parameters, the ID equals four.

57
00:04:25,040 --> 00:04:30,260
So these are the important attributes that we are going to use when developing our lambda function.

58
00:04:30,260 --> 00:04:34,640
So that's why I'm saving these incoming JSON objects from the HTTP API.

59
00:04:34,700 --> 00:04:35,960
So very good.

60
00:04:35,960 --> 00:04:40,840
So let's continue to collect our HTTP APIs.

61
00:04:40,910 --> 00:04:44,930
So this time I'm going to post product with the new product payload.

62
00:04:44,930 --> 00:04:48,680
For that purpose, open the postman and create a new request.

63
00:04:48,740 --> 00:04:53,750
And in this request I'm going to copy this request and paste in here.

64
00:04:53,780 --> 00:04:58,280
This is very similar we to get, but we should change the method as a post.

65
00:04:58,400 --> 00:05:01,970
So when we change the post we should provide the payload.

66
00:05:01,970 --> 00:05:08,060
Also, in order to do that, please click the Body Select Row and click the JSON.

67
00:05:08,060 --> 00:05:13,820
And in here I'm going to provide a JSON object about the product.

68
00:05:13,820 --> 00:05:16,250
Product Jason has name and price.

69
00:05:16,280 --> 00:05:18,830
Think about that is the product item in Dynamo.

70
00:05:18,830 --> 00:05:19,340
DB.

71
00:05:19,340 --> 00:05:27,020
So now we are going to send the post request to this URL, this slash product and providing these JSON

72
00:05:27,020 --> 00:05:30,500
object as a payload body of this exit postal version.

73
00:05:30,500 --> 00:05:37,070
Just click the send button and see that again the lambda function return back the hello message.

74
00:05:37,070 --> 00:05:41,960
So the idea is that we should collect the event JSON object for that purpose.

75
00:05:41,960 --> 00:05:45,380
Open the cloud box for the product function.

76
00:05:45,410 --> 00:05:49,190
Come to latest log stream and come here.

77
00:05:49,280 --> 00:05:58,610
So copy this log open or we just do a code and come here, paste the event post JSON file.

78
00:05:59,770 --> 00:06:02,050
Remove the first line and save this file.

79
00:06:02,140 --> 00:06:05,170
Okay, let's examine this Jason file also.

80
00:06:05,200 --> 00:06:07,960
So these are the important attributes that we solve.

81
00:06:07,960 --> 00:06:12,250
That root key is post product and raw pet is product.

82
00:06:12,310 --> 00:06:19,690
And if you scroll down, we can see that we will see the incoming information under the event.

83
00:06:19,930 --> 00:06:25,440
But the information, the name is Price, also including this JSON object.

84
00:06:25,450 --> 00:06:28,210
We will pass this JSON into our lambda function.

85
00:06:28,210 --> 00:06:33,430
So if there is a post request, we should pass by the information in order to get payload and insert

86
00:06:33,430 --> 00:06:34,360
product record.

87
00:06:34,720 --> 00:06:42,670
As you can see that we have understood that how http api triggered to lambda function with JS object

88
00:06:42,670 --> 00:06:46,570
and we save this event JSON object into our visual project.

89
00:06:46,750 --> 00:06:50,260
Now it is time to develop our lambda function with these payloads.
