title: passing POST request body through Amazon API Gateway to Lambda
body: <p>I have a AWS Lambda function written in Java, that gets triggered by an AWS API Gateway call. </p>
  
  <p>I am trying to make a <code>POST</code> request to one of the endpoints with a JSON as payload.</p>
  
  <pre><code>curl -H "Content-Type: application/json" -X POST -d '{"firstName":"Mr", "lastName":"Awesome"}' https://someexample.execute-api.eu-central-1.amazonaws.com/beta/MethodHandlerLambda
  </code></pre>
  
  <p>The gateway will then <em>detect</em> the <code>Content-Type</code> and pass all request parameters (including the body) through a default <a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html" rel="noreferrer">template</a>. The interesting part is this one</p>
  
  <pre><code>#set($allParams = $input.params())
  {
  "body-json" : $input.json('$'),
   ....
  </code></pre>
  
  <p>It is supposed to present me with a <code>Map&lt;String, Object&gt;</code> that is passed to my Java method:</p>
  
  <pre><code>public void myHandler(Map&lt;String, Object&gt; input, Context context){
      input.keySet().forEach((key) -&gt; {
          System.out.println(key + " : " + input.get(key));
      });
  }
  </code></pre>
  
  <p>And the result <em>should</em> be something like this:</p>
  
  <pre><code>body-json : {"firstName":"Mr", "lastName":"Awesome"}
  ...
  </code></pre>
  
  <p>But what I am getting is this:</p>
  
  <pre><code>body-json : {firstName=Mr, lastName=Awesome}
  </code></pre>
  
  <p>Another possibility would be to pass the whole body as string:</p>
  
  <pre><code>"body" : $input.body
  </code></pre>
  
  <p>but that again just "converts" to <code>key=value</code> instead of <code>key:value</code></p>
  
  <p><strong>How do I have to configure the template to simply pass me the body so I can use it in a JSON parser?</strong></p>