[英]How should I test a DynamoDB PutItem API made with AWS API Gateway in Postman?
[英]How should I modify the response which is returned to me by AWS DynamoDB Query through AWS API Gateway?
我通过 AWS API 网关为 AWS DynamoDB 构建了查询 API。 这是我在成功查询后得到的示例响应:
{
"Count":2,
"Items":[
{
"StoreID":{
"S":"STR100"
},
"OrderID":{
"S":"1019"
},
"Date":{
"S":"22nd May"
}
},
{
"StoreID":{
"S":"STR100"
},
"OrderID":{
"S":"1020"
},
"Date":{
"S":"22nd May"
}
}
],
"ScannedCount":2
}
我想要做的是,当响应到达 API 网关时(在它到达用户之前)我想修改它。 我想对即将到来的响应进行以下更改-
ScannedCount
值。 (保持Count
一)"S": "<value>"
:值应该直接出现,例如"StoreID": "STR100"
因此,修改后的响应应如下所示:
{
"Count":2,
"Items":[
{
"StoreID":"STR100",
"OrderID":"1019",
"Date":"22nd May"
},
{
"StoreID":"STR100",
"OrderID":"1020",
"Date":"22nd May"
}
]
}
我希望你能理解我的问题 - 任何帮助表示赞赏!
谢谢: :)
按照博客文章使用 Amazon API 网关作为 DynamoDB 的代理
导航到集成响应并通过选择左侧的箭头展开 200 响应代码。 在 200 响应中,展开映射模板部分。 在 Content-Type 中选择 application/json 然后选择 Output Passthrough 旁边的铅笔图标。
对于您的示例,模板应如下所示:
#set($inputRoot = $input.path('$'))
{
"Count": "$inputRoot.Count",
"Items": [
#foreach($elem in $inputRoot.Items) {
"StoreID": "$elem.StoreID.S",
"OrderID": "$elem.OrderID.S",
"Date": "$elem.Date.S"
}#if($foreach.hasNext),#end
#end
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.