Reputation: 11109
My scenario is when my Lambda function's Api endpoint is hit, with a post variable, i want my Lambda to invoke a database connection and get some results.
So the first step is to create an API Gateway endpoint and I have problem creating the POST method with parameters
Here is what i did till now:
and response is as follows in the console
How do i create parameters for the api here? and how do i test it? I have my lambda function ready, that takes in a String as input and returns a String as response.
Can someone guide me for the next steps..
Upvotes: 5
Views: 16735
Reputation: 1710
Great step by step explanation of Serverless API on AWS: Serverless API on AWS in 10 minutes
Upvotes: 2
Reputation: 7344
The answer by Frederic is very good, I'll just leave another example in the docs -> http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
Further down on that page is an example for Param Mapping which will proxy any incoming parameters to Lambda. You still need to explicitly state any incoming parameters that you expect clients to send in the Method Request.
Upvotes: 0
Reputation: 53703
You can check the Create and Test a POST Method
you do not mention the parameters in the lambda definition, the parameter will be taken from the request directly (so in future if you change your lambda code to take new parameters, you dont need to change the configuration
To test :
In the Method Execution pane, in the Client box, and then choose TEST.
Expand Request Body, and type the following:
{ "name": "User" <or any other parameter that you expect> }
Choose Test. If successful, Response Body will display the reply from your lambda execution
For example here an example post api I had
so again for POST API you dont define the parameters
If you were doing GET API you would define the query parameters
Upvotes: 5