Could not parse request body into json: Unexpected character (\'-\' (code 45)) AWS Lambda + API + Postman
<p>I have been trying for a few days to get a parameter sent from the API Gateway in AWS to a Lambda function and I am having no success. </p>

<p>I decided to start from the beginning so I followed their walkthrough (<a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html#getting-started-new-lambda" rel="noreferrer">http://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started.html#getting-started-new-lambda</a>)</p>

<p>I have checked this walkthrough twice and I have followed the steps to the letter. </p>

<h1>Problem</h1>

<p>When I test the API from Postman or in Swift I am getting the error:</p>

<blockquote>
  <p>{"message": "Could not parse request body into json: Unexpected character (\'-\' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n at [Source: [B@c036d15; line: 1, column: 3]"}</p>
</blockquote>

<p>In postman, When I view the result as JSON I just get</p>

<blockquote>
  <p>Bad String</p>
</blockquote>

<h1>Lambda Function</h1>

<p>The function is the basic example from the Walkthrough:</p>

<pre><code>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}); // SUCCESS with message
};
</code></pre>

<p>When Tested from the Lambda Console and with the Test data I get the result:</p>

<pre><code>{
    "Hello": "TestUser123"
}
</code></pre>

<p>When Tested from the API Gateway Test, The result is also:</p>

<pre><code> {
    "Hello": "TestUser123"
}
</code></pre>

<p>Can anyone see why both test consoles are allowing this work but when tested with POSTMAN or used within a Swift Script it does not work ?</p>

<h1>Edit 1</h1>

<p>In postman, I have set the content-type to <strong>application/json</strong></p>

<p>The script returns the default:</p>

<pre><code> {
    "Hello": "user"
}
</code></pre>

<p>However, When I add in the parameters <strong>name</strong> and <strong>TestUser123</strong> in POSTMAN, this is when it returns the error.</p>

<h1>Update 1</h1>

<p>Ok, so I changed the mapping template to one that I found on another answer:</p>

<pre><code>{ "name": "$input.params('name')" }
</code></pre>

<p>Now the result is:</p>

<pre><code>{
   "Hello": ""
}
</code></pre>

<p>Any Ideas why it is not getting the name?</p>