我需要帮助反应体模板 . 我正在直接使用APIGateway(没有lambda)在DynamoDB中使用POST来“PutItem” .
新项目已成功添加,但响应在200处为空
我需要的是1 - 新行数据2 - 状态3 - 消息
{
"data": [],
"status": "Success",
"message": "Updated Succesfully"
}
不使用lambda ......这可能吗?
我尝试了很多东西,即
#set($inputRoot = $input.path('$'))
{"templateId": "$elem.templateId.S",
"templateFileName": "$elem.templateFileName.S"}
但它显示为null .
当我运行Test @API Gateway时,这是我的日志
2月17日星期六06:22:18 UTC 2018:转换后的 endpoints 请求体:
{
"TableName": "xyz-mobilehub-9260364_Template_Table",
"Item": {
"templateId": {
"S": "APIGateway"
},
"templateFileName": {
"S": "breaking-news-story-01-18-2016"
},
"templateName": {
"S": "Just Saying Thank You"
},
"templateType": {
"S": "I really enjoyed this story!!"
}
}
}
星期二2月17日06:22:18 UTC 2018:发送请求到https://dynamodb.us-east-1.amazonaws.com/?Action=PutItem星期二2月17日06:22:18 UTC 2018:收到回复 . 积分延迟:33 ms星期六2月17日06:22:18 UTC 2018:转换前的 endpoints 响应体:{}星期六2月17日06:22:18 UTC 2018: endpoints 响应标头:{Server = Server,Connection = keep-alive, x-amzn-RequestId = RE631UNS84TACTMP4TE752UK0BVV4KQNSO5AEMVJF66Q9ASUAAJG,x-amz-crc32 = 2745614147,Content-Length = 2,Date = Sat,17 Feb 2018 06:22:17 GMT,Content-Type = application / x-amz-json-1.0}星期二2月17日06:22:18 UTC 2018:转换后的方法响应体:
{
"templateId": "",
"templateFileName": "",
}
星期二2月17日06:22:18 UTC 2018:方法响应 Headers :{X-Amzn-Trace-Id = Root = 1-5a87ca19-62a291f9a923480f5c62884f,Content-Type = application / json} Sat Feb 17 06:22:18 UTC 2018 :成功完成执行Sat Feb 17 06:22:18 UTC 2018:方法已完成,状态:200
1 回答
转到API网关中的Integration Response并以您希望的方式提供响应 . 请看下面的截图,
选择集成响应,
在生成模板下提供您的JSON数据