用于context.requestTime的API网关映射模板为空

时间:2019-04-15 19:17:06

标签: amazon-web-services aws-api-gateway api-gateway

我正在尝试让API网关充当DynamoDB的代理,并且我目前正在通过简单的POST调用进行测试,以将$context.requestId$context.requestTime附加到我的表。我收到以下错误消息:

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

发送的是:

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": ""
    }
  }
}

我在Integration Request中拥有的映射模板是:

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

我尝试将$context.requestTime更改为$context.requestTimeEpoch,但遇到相同的错误。

1 个答案:

答案 0 :(得分:1)

我知道这是前一段时间发布的,但是根据AWS开发人员的说法:

  

“目前,[$ context.requestTime]仅在API已部署并且API调用已被部署到部署阶段时可用。”

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