title: Raw body payload in AWS API Gateway Body Mapping Template
body: <p>For some reason I'm having a hard time getting the raw body from within the <code>event</code>. It's logging the <code>$input.body</code> as json for a <code>application/json</code> content-type. <a href="http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#input-variable-reference">The docs say that that should contain the raw payload.</a></p>
  
  <p>Here my Integration Request Body Mapping Template:</p>
  
  <pre><code>{
    "body" : $input.json('$'),
    "rawBody": $input.body,
    "headers": {
      #foreach($header in $input.params().header.keySet())
      "$header": "$util.escapeJavaScript($input.params().header.get($header))" #if($foreach.hasNext),#end
  
      #end
    },
    "method": "$context.httpMethod",
    "params": {
      #foreach($param in $input.params().path.keySet())
      "$param": "$util.escapeJavaScript($input.params().path.get($param))" #if($foreach.hasNext),#end
  
      #end
    },
    "query": {
      #foreach($queryParam in $input.params().querystring.keySet())
      "$queryParam": "$util.escapeJavaScript($input.params().querystring.get($queryParam))" #if($foreach.hasNext),#end
  
      #end
    }  
  }
  </code></pre>
  
  <p>Here's the payload example:</p>
  
  <pre><code>{
    "event": {
      "body": {
        "hello": "meow"
      },
      "rawBody": {
        "hello": "meow"
      },
      "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Accept-Language": "en-US",
        "Cache-Control": "no-cache",
        "CloudFront-Forwarded-Proto": "https",
        "CloudFront-Is-Desktop-Viewer": "true",
        "CloudFront-Is-Mobile-Viewer": "false",
        "CloudFront-Is-SmartTV-Viewer": "false",
        "CloudFront-Is-Tablet-Viewer": "false",
        "CloudFront-Viewer-Country": "US",
        "Content-Type": "application/json",
        "Host": "7nuy7lymef.execute-api.us-east-1.amazonaws.com",
        "Origin": "file://",
        "Postman-Token": "0ce7c6f4-3864-c9b4-f2db-739737b2ba49",
        "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Postman/4.2.2 Chrome/47.0.2526.73 Electron/0.36.2 Safari/537.36",
        "Via": "1.1 1eea0bca59557555878da4d9775c509f.cloudfront.net (CloudFront)",
        "X-Amz-Cf-Id": "SDjaGcuJ5eVkOMMCn6M3vGaVicA1fuA7h0bUYE4ARlKupO60eeYNFA==",
        "X-Forwarded-For": "206.71.230.14, 205.251.250.135",
        "X-Forwarded-Port": "443",
        "X-Forwarded-Proto": "https",
        "x_example_header": "my awesome header"
      },
      "method": "POST",
      "params": {},
      "query": {
        "example_param": "myawesomeparam"
      }
    },
    "context": {
      "callbackWaitsForEmptyEventLoop": false,
      "logGroupName": "/aws/lambda/reggi-log-post",
      "logStreamName": "2016/06/08/[$LATEST]aad04e0e46614c288ac8ca43d0a95076",
      "functionName": "reggi-log-post",
      "memoryLimitInMB": "128",
      "functionVersion": "$LATEST",
      "invokeid": "6e4e1e13-2dc1-11e6-a1f7-4dad3a8eb122",
      "awsRequestId": "6e4e1e13-2dc1-11e6-a1f7-4dad3a8eb122",
      "invokedFunctionArn": "arn:aws:lambda:us-east-1:562508364089:function:reggi-log-post"
    }
  }
  </code></pre>
  
  <ul>
  <li>Is there any way to access the raw body from this request?</li>
  <li>Is there any way to change the content-type to accept all types?</li>
  </ul>