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

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.