pedro.olimpio pedro.olimpio - 1 year ago 107
Node.js Question

How can I integrate API Gateway with Lambda through GET method

I'm deeply confused trying to integrate

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

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

It happens because the parameters was not arriving to the function and
variable is

I'm trying to execute a lambda function with
at this form:{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);"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.

Answer Source

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')"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download