I have defined my AWS::ApiGateway::Method like this
GetOrdersMethod:
Type: "AWS::ApiGateway::Method"
Properties:
ApiKeyRequired: true
AuthorizationType: "AWS_IAM"
HttpMethod: "GET"
RequestParameters:
method.request.querystring.orderId: false
ResourceId:
Ref: "GetOrdersPathResource"
RestApiId:
Ref: "GetOrders"
Integration:
Type: "AWS_PROXY"
IntegrationHttpMethod: "POST"
RequestTemplates:
application/json: !Join ["", ["{","\"orderId\": \"$input.params('orderId')\"","}"]]
Uri: !Join ["", ["arn:aws:apigateway:", !Ref "AWS::Region", ":lambda:path/2015-03-31/functions/",!GetAtt GetProgramsLambdaFunction.Arn, "/invocations"]]
My handler is defined like this
public class ProgramHandler implements RequestHandler<Request, String>{
private LambdaLogger logger;
@Override
public String handleRequest(Request request, Context context) {
logger = context.getLogger();
logger.log("FROM LOGGER: ======= LAMBDA INVOKED ======");
logger.log("Input value: " +request.getOrderId());
System.out.println("======= LAMBDA INVOKED ======");
System.out.println("Input value: " +request.getMarketplaceId());
return "Lambda Invoked successfully";
}
}
And the Request is a simple java pojo with orderId as only fields which has necessary GETTERS and SETTERS
When i tested the API Gateway, I saw that in my lambda logs, order id was null. However, I do see it being passed as querystring in over logs ... here it is
Tue Apr 25 21:57:31 UTC 2017 : Endpoint request body after transformations: {"resource":"/xxxx","path":"/xxxx","httpMethod":"GET","headers":null,"queryStringParameters":{"orderId":"32"},"pathParameters":null,"stageVariables":null,"requestContext":{"accountId":"xxxxxxx","resourceId":"xxxxx","stage":"test-invoke-stage", ... }
Why I am getting null orderId in my handler?