In this video we are going to enter test rest API and lambda function with incoming rest API event JSON
object to perform business logic.
So let's get started.
For that purpose, I have created a separate folder in our juju code project.
So these are the requests that we are going to send using to Postman and these are the response from
coming from the lambda functions.
So let's get started to get these URLs.
Please open the console, go to API, get a product API, go to states under the prod, select the get
method and copy from this emotional.
So we are pasting these with the postman open any request and paste in here we are going to send get
request, get product, click the send button.
So as you can see that the message is response.
In here there is a message successfully finished operation so the body is processing get all products.
So if you look at the operation, you can see that there is an undefined.
So that means there's an error in our code.
So if you open the code, please open the indexes.
You can see that instead of we are passing the method, we are passing the raw k, it is leaving from
the http api.
So that's why please update this method for everywhere in your indexes.
Copy these codes and go to the lambda and update our codes in here.
Let me copy and paste all and make sure that you are returning the method.
Deploy the lambda function.
Okay, now come back to postman and send the request again.
So this time we can see that we are successful to get request in here.
So the message is correct and successfully response back to lambda function.
So I'm continuing the other request.
So other request is get product by ID for that purpose.
Copy this URL, create a new request and come here and in here I'm writing a random product ID and send
request and verify that we are sending the HTTP get method and we are proceeding get product ID with
this ID information.
So very good.
So another request is post request.
So I'm going to copy your app from here and paste in here.
This will be the post product change the estimated as a post and this time I am going to set the body
raw JSON and you can get the body information from our application command text window.
I'm going to copy payload in here and paste in here.
So basically we will create a new product with a HTTP post request and click the send button.
So we have verified that we successfully finish the post operation and these are the payloads that we
need to pass these payload with the JSON methods.
Okay.
We successfully get response from the post method and the last method is the HTTP delayed.
So delayed by ID.
So that's why I am.
Copy this url and come here, paste here and change http method as a delete.
And now I am going to delete this product.
ID send a method and get back to response.
The message is successfully finished.
Delete operation and processing it by product ID, which product ID is in here.
So as you can see that we have successfully test our rest API and lambda functions and finish the hands
on lab, which is the building code microservices with rest API and lambda functions.