I am implementing an aws lambda function coded in java using the aws-lambda-java-events library. For troubleshooting purpose I am for now just trying to respond back with the same request body
public class LambdaFunctionHandler implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
@Override
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent input, Context context) {
return new APIGatewayProxyResponseEvent().withBody(input.getBody());
}
}
I have defined the above lambda function and an api gateway but I get the input.getBody as null. The output of the lambda function is an empty json object
{}
I tested this through the AWS lambda test console. The execution succeeds and the output is as above. The api gateway integration request is configured to call the above lambda function on a POST method.
Below are my queries
- How do I get the aws test event json as part of the
APIGatewayProxyRequestEvent getBody()string? - How do I get the request body passed to the API Gateway POST method in the
APIGatewayProxyRequestEvent getBody()string variable? Do I need to define a mapping template? If so how should it look like (I made multiple attempts but with no success)
The request body I want to pass to the API gateway POST method through POSTMAN is
{
"question":"Hello, how are you doing?"
}
Thanks!


