3

I am working aws lambda with API gateway. for my compare-yourself-api resource I created a sub resource called field (please refer screenshot).

when I am testing it, I can see the request uri: /compare-yourself-api/test1. I can see test1 in request but not sure how to access that field in my functionhandler. I tried Map<String,String> as input in place of object but still the same issue. I was getting empty value.

my output from Gateway Method Test screen is: "{} Hello from Lambda!"

Empty curly braces with out any object.

Here is my lambda function.

package com.amazonaws.lambda.demo;

import com.amazonaws.services.lambda.runtime.Context;
import com.amazonaws.services.lambda.runtime.RequestHandler;

public class LambdaFunctionHandler implements RequestHandler<Object, String> {

    @Override
    public String handleRequest(Object input, Context context) {
        context.getLogger().log("Input: " + input);


        // TODO: implement your handler
        return input+"   Hello from Lambda!";
    }

}

Please suggest me how can I get the pathvariable in Lambda function handler java.

Gateway resources and methods

user12
  • 239
  • 2
  • 6
  • 18
  • I found solution from other similar question. https://stackoverflow.com/questions/41762462/how-to-get-the-path-param-value-in-java-aws-lambda-function . Sorry.. – user12 Feb 26 '18 at 11:33

1 Answers1

0

Your parameter is passed as query string. You can find it from request. Something like this How to pass a querystring value from AWS API Gateway to a Lambda C# function

Shetty
  • 1,792
  • 4
  • 22
  • 38