In this video, we are going to understand how rest API triggered a lambda with even an object.
And after that we will develop our lambda function with incoming event from the rest API.
So we will in this stage we will get the event JSON object from rest API to a lambda with different
active methods, get product, get product, buy ID, post product, delayed product ID.
We will get all these events, objects and the loop are a lambda function.
So let's get started.
In order to do that, I'm going to create an EVE lecture folder into our visual code.
So as you can see that we will send these requests to our API, Gateway Rest API and we will call this
event get get py ID and post JSON document.
So let's get started.
In order to do that, in the last video we have invoke our API, we digital copy this URL, you can
copy from the API gateway.
Also go to API Gateway and get the ID from here.
Let me show copy product API.
If you go to the product and get you can get the ID from in here.
Let me go to the stage under the plot, under the product, in the get method, you can see the inaugural
copy this URL and go to the postman.
So we will perform a HTTP, get operation to the product and click the send button.
So this will respond back to us.
Hello from Lambda because we didn't implement Lambda function yet, but it is we will collect the incoming
event JSON.
So go to lambda function to get this HTTP, get product method log information for that purpose, go
to lambda function and go to monitoring v cloud watch looks.
And go to the latest lucid dream and come here as remember that we are put to console log operation
into our lambda function.
So that's why we can copy incoming event and pass to our.
We used to do code event, get JSON file, go on top of this page, remove the first line and save this
JSON file.
As you can see that this is the get product operation from rest API to Lambda function and see that
the parameters are really different from the HTTP API.
This time we have resource, PID and HTTP method that we can understand.
This is the gate product method and if you scroll down, you can see different and additional delays
in here.
For example, query parameters, request context.
If you scroll down by the information and so on, this is a bit different from triggering the HTTP API.
This time we will take it from the rest API and we will consider about these important parameters which
are the HTP method, pet parameters and setting parameters, resource, PET and so on.
So let's continue to our test to complete all JSON files.
So let me go back to Postman and copy this URL, create any request.
And this time I'm going to send, for example, different ID information if I get the query string,
for example, category equal form.
Let's see how it is triggered to our lambda function.
Eat the send button.
So as you can set this, return the same text message.
And now let's see the latest looks for the purpose.
Go to cloud voice logs, go to product function, open the latest log stream and copy from the last
log stream.
Copy from here and open the our visitor code and paste in here.
Get by ID.
On top of this page, remove the first line, save this file.
So as you can see that this time I have in tested product get product by ID so resource and pet is seems
different way and this time if you scroll down we can see create setting parameters and if you scroll
down we can also see pet parameters.
So we understand how the trigger from the rest API and how we can get these parameters from these events
and file.
Let's continue to our test.
So if you check the command text, we will follow these two one and now I am going to send a post payload
for that purpose.
Go to our postman copy URL from here, create new request and paste in here.
This will be post method, so change the method as a post.
And now we are going to set body information, body roll, JSON and copy from our payload in here.
We can put the run on payload.
Also, it is not important since we didn't develop the product lambda function OC just sent the HTTP
post request to the product domain.
Yes, the text message comes successfully.
That means lambda function invoke successfully.
Go to cloud watch logs and come to latest look.
Copy from the latest look and taste to the hour, which is the code to the event post JSON, go on top
and remove design.
This time you can see the method is post and the resource is product.
If you scroll down this time you will see the body information in here we will.
These body parts, this information and use this information when using post operation into the product
domain.
Okay, very good.
As you can see that we have sent different parameters and different ways to our application lambda function
and see incoming event json object.
So the important parameter is in here resource pet and estimated and we can also check the parameters
in the get by ID and we can also check the information when we send the post information.
So if there is a post request, we should pass the information in order to get payload and insert product
record.
As you can see that we have understood how this API triggered the lambda function with even JSON object.
Now it is time to develop our lambda function with these payloads.