1

I'm deeply confused trying to integrate AWS API Gateway with AWS Lambda, because i'm trying to execute a lambda function through the GET method and always my function is returning invalid parameter.

{"errorMessage":"Error - Invalid Group ID - undefined - alexa id: undefined"}|

It happens because the parameters was not arriving to the function and idgrupo variable is <=0.

I'm trying to execute a lambda function with URL at this form:

domain.execute-api.us-east-1.amazonaws.com/prod/chkneopairtoken?idgrupo=3823&clientId={321356-6666-4745}&keypair=90809276

And in my Lambda function i'm doing it:

var idgrupo = event.idgrupo;
var alexaClientId = event.clientId;
var keypair = event.keypair;

if (idgrupo > 0){

} else{
        console.log("Error - Invalid Group ID - " + idgrupo + " - alexa id: " + alexaClientId + " - ");
        //callback(null, "Error - Invalid Group ID - " + idgrupo + " - alexa id: " + alexaClientId);
        context.fail("Error - Invalid Group ID - " + idgrupo + " - alexa id: " + alexaClientId);
    }

Are there the possibility to do what i'm trying to do? I think it is not an integration error between API Gateway and AWS Lambda, because the function returns my custom error message, and I believe it is a transfer parameters error.

2
  • It sounds like you haven't mapped the request parameters in your API Gateway mapping template, so they aren't available to your Lambda function. Commented Aug 18, 2016 at 14:05
  • I understood, but I'll map it in "Method Request" or in "Integration Request"? Do you have any example to show me? Thank you Commented Aug 18, 2016 at 14:18

2 Answers 2

1

Go back to the "Integration Request" of your resource GET, under "Body Mapping Templates"

  1. Select for the recommended option for "Request body passthrough"
  2. Add a mapping template (clicking on the action "Add mapping template")
  3. Write "application/json" for the content type
  4. Add this template

{
    "idgrupo" : "$input.params('idgrupo')",
    "clientId" : "$input.params('clientId')",
    "keypair" : "$input.params('keypair')"
}
Sign up to request clarification or add additional context in comments.

Comments

0

In your API Gateway console, under "Integration Request", in the "Mapping Template" section, create a template for the content-type that you are submitting, and then just select "Method Request passthrough". This will pass everything through to the Lambda function.

Then in your Lambda function code you will need to reference those URL parameter values via event.params.idgrupo, event.params.clientId etc.

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.