title: How to Access header in AWS Lambda in 2018
body: <p>Yes, I know this is a duplicate, however things have changed since the Mapping Template solution provided <a href="https://kennbrodhagen.net/2015/12/02/how-to-access-http-headers-using-aws-api-gateway-and-lambda/" rel="noreferrer">here</a>, <a href="https://stackoverflow.com/questions/31372167/how-to-access-http-headers-for-request-to-aws-api-gateway-using-lambda">here</a> and <a href="https://stackoverflow.com/questions/38452587/how-to-access-header-values-in-aws-lambda-function">here</a> was devised. With a proxy integration (the AWS recommended approach), there is no access to templates. So how do you get to the headers now?</p>
  
  <p>I have tried just using the object model with things like:</p>
  
  <pre><code>event.headers
  event.headers["X-Requested-With"]
  
  var headerItem = "x-requested-with"
  event.headers.headerItem
  </code></pre>
  
  <p>etc. and nothing seems to be defined.</p>
  
  <p>The event, according to Cloudwatch, is:</p>
  
  <pre><code>{
      "resource": "/contactformlambda",
      "path": "/contactformlambda",
      "httpMethod": "POST",
      "headers": {
          "Accept": "application/json, text/plain, */*",
          "Accept-Encoding": "gzip, deflate, br",
          "Accept-Language": "en-US,en;q=0.9",
          "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": "AU",
          "content-type": "text/plain",
          "Host": "ovo5xmxf7e.execute-api.ap-southeast-2.amazonaws.com",
          "origin": "http://localhost:4200",
          "pragma": "no-cache",
          "Referer": "http://localhost:4200/contact",
          "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36",
          "Via": "2.0 49d473f12cd3746d92748f257e16ca9e.cloudfront.net (CloudFront)",
          "X-Amz-Cf-Id": "7_PvRhkwbB7wmB1n8EFgE9s84q1xPYZ_uKwAjwYPXSv383M-fmDTgQ==",
          "X-Amzn-Trace-Id": "Root=1-5a826e92-b4425f8069686c808cc2d500",
          "X-Forwarded-For": "155.144.114.41, 54.240.152.46",
          "X-Forwarded-Port": "443",
          "X-Forwarded-Proto": "https",
          "x-requested-with": "Angular5"
      },
      "queryStringParameters": null,
      "pathParameters": null,
      "stageVariables": null,
      "requestContext": {
          "requestTime": "13/Feb/2018:04:50:26 +0000",
          "path": "/prod/contactformlambda",
          "accountId": "499908792600",
          "protocol": "HTTP/1.1",
          "resourceId": "i6i1qv",
          "stage": "prod",
          "requestTimeEpoch": 1518497426058,
          "requestId": "683aeec6-1079-11e8-a419-318ae32195ef",
          "identity": {
              "cognitoIdentityPoolId": null,
              "accountId": null,
              "cognitoIdentityId": null,
              "caller": null,
              "sourceIp": "155.144.114.41",
              "accessKey": null,
              "cognitoAuthenticationType": null,
              "cognitoAuthenticationProvider": null,
              "userArn": null,
              "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36",
              "user": null
          },
          "resourcePath": "/contactformlambda",
          "httpMethod": "POST",
          "apiId": "ovo5xmxf7e"
      },
      "body": "{\"subject\":\"Enquiry from ZenithWebFoundry\",\"name\":\"Mike\",\"number\":\"0415118180\",\"email\":\"rmjcoxon@gmail.com\",\"comment\":\"this is a test from localhost\"}",
      "isBase64Encoded": false
  }
  </code></pre>
  
  <p>The "x-requested-with" header is in there, but it never seems to be defined, when I try to access it programmatically</p>