Search code examples
amazon-web-servicesaws-api-gatewayapi-gateway

API Gateway Mapping Template for context.requestTime is Blank


I'm attempting to to have an API Gateway act as a proxy to DynamoDB and I'm currently testing with a simple POST call to append the $context.requestId and $context.requestTime to my table. I am getting the following error message:

{
"__type": "com.amazon.coral.validate#ValidationException",
"message": "One or more parameter values were invalid: An AttributeValue may not contain an empty string"
} 

and what is sent is:

Mon Apr 15 19:10:24 UTC 2019 : Endpoint request body after transformations: {
  "TableName": "BurgerOrders",
  "Item": {
    "OrderId": {
      "S": "1f54a90b-5fb2-11e9-8b31-c9003bb71ec2"
    },
    "RequestTime": {
      "S": ""
    }
  }
}

The mapping template within Integration Request that I have is:

{
  "TableName": "BurgerOrders",
  "Item": {
    "OrderId": {
      "S": "$context.requestId"
    },
    "RequestTime": {
      "S": "$context.requestTime"
    },
  }
}

I've tried to change $context.requestTime to $context.requestTimeEpoch and I get the same error.


Solution

  • I know this was posted a while back, but according to an AWS dev:

    "At this time, [$context.requestTime] is only available when the API has been deployed and API call was invoked to deployed stage."

    Source: https://forums.aws.amazon.com/thread.jspa?messageID=697652