I have been trying for several days to get the parameter sent from the API gateway in AWS to the Lambda function, and I have no success.
I decided to start from the beginning, so I followed their walkthrough ( http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html#getting-started-new-lambda )
I checked this walkthrough twice and I followed the steps to writing.
Problem
When I test the API from Postman or in Swift, I get an error message:
{"message": "Unable to parse the request body in json: Unexpected character (\ '- \' (code 45)) in numeric value: expected digit (0-9) to follow the minus for the actual numeric value \ n in [Source: [B @ c036d15; row: 1, column: 3] "}
At the postman, When I view the result as JSON, I just get
Bad line
Lambda function
A function is a basic example from the Walkthrough:
console.log('Loading event'); exports.handler = function(event, context) { var name = (event.name === undefined ? 'No-Name' : event.name); console.log('"Hello":"' + name + '"'); context.done(null, {"Hello":name});
When testing with the Lambda Console and test data, I get the result:
{ "Hello": "TestUser123" }
When testing from the Gateway API test, the result is also:
{ "Hello": "TestUser123" }
Can anyone understand why both test consoles allow this work, but when they are tested using POSTMAN or used in Swift Script, it does not work?
Change 1
In postman, I set the content type application / json
Script returns the default value:
{ "Hello": "user" }
However, when I add the name and TestUser123 to POSTMAN in the parameters, this is when it returns an error.
Update 1
So, I changed the mapping pattern to the one I found on another answer:
{ "name": "$input.params('name')" }
Now the result:
{ "Hello": "" }
Any ideas why he is not getting the name?