Nir*_*r-Z 5 amazon-web-services amazon-dynamodb aws-api-gateway
我已经设置了与 DynamoDB 的 API 端点集成。我想使用查询字符串参数作为查询过滤器来查询表。不幸的是,我最终得到了错误:
Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Run Code Online (Sandbox Code Playgroud)
不知道根本原因是什么。
为了做到上述,我采取了以下步骤:
1)在API网关中设置get方法
2)在方法请求中,我向 URL 查询字符串参数添加了一个参数

3) 在集成请求中,我在 URL 查询字符串参数中添加了与步骤 2 相同的参数

4)在 DynamoDB 表中,我为要查询的列添加了一个新索引
5)在身体映射模板中:
{
"TableName": "tjusers",
"IndexName" "badge-index",
"KeyConditionExpression": "badge = :v1",
"ExpressionAttributeValues": {
":v1": {
"S": "$input.params('badge')"
}
}
}
Run Code Online (Sandbox Code Playgroud)
例外:
xecution log for request f0081606-b521-11e8-adb2-cd8092221b33
Mon Sep 10 17:50:00 UTC 2018 : Starting execution for request: f0081606-b521-11e8-adb2-cd8092221b33
Mon Sep 10 17:50:00 UTC 2018 : HTTP Method: GET, Resource Path: /db/users
Mon Sep 10 17:50:00 UTC 2018 : Method request path: {}
Mon Sep 10 17:50:00 UTC 2018 : Method request query string: {badge=18323}
Mon Sep 10 17:50:00 UTC 2018 : Method request headers: {}
Mon Sep 10 17:50:00 UTC 2018 : Method request body before transformations:
Mon Sep 10 17:50:00 UTC 2018 : Endpoint request URI: https://dynamodb.us-west-2.amazonaws.com/?Action=Query&badge=11111
Mon Sep 10 17:50:00 UTC 2018 : Endpoint request headers: {Authorization=****************************************************************************************************************************************************************************************************************************************************************************************feb2ac, X-Amz-Date=20180910T175000Z, x-amzn-apigateway-api-id=53zgcztitj, Accept=application/json, User-Agent=AmazonAPIGateway_53zgcztitj, X-Amz-Security-Token=AgoGb3JpZ2l....
Mon Sep 10 17:50:00 UTC 2018 : Endpoint request body after transformations: {
"TableName": "tjusers",
"IndexName" "badge-index",
"KeyConditionExpression": "badge = :v1",
"ExpressionAttributeValues": {
":v1": {
"S": "11111"
}
}
}
Mon Sep 10 17:50:00 UTC 2018 : Sending request to https://dynamodb.us-west-2.amazonaws.com/?Action=Query&badge=18323
Mon Sep 10 17:50:00 UTC 2018 : Received response. Integration latency: 11 ms
Mon Sep 10 17:50:00 UTC 2018 : Endpoint response body before transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Mon Sep 10 17:50:00 UTC 2018 : Endpoint response headers: {Server=Server, Date=Mon, 10 Sep 2018 17:49:59 GMT, Content-Type=application/x-amz-json-1.0, Content-Length=60, Connection=keep-alive, x-amzn-RequestId=ODMJ814D1GBN875T6MTR7BUHGVVV4KQNSO5AEMVJF66Q9ASUAAJG, x-amz-crc32=3948637019}
Mon Sep 10 17:50:00 UTC 2018 : Method response body after transformations: {"__type":"com.amazon.coral.service#SerializationException"}
Mon Sep 10 17:50:00 UTC 2018 : Method response headers: {X-Amzn-Trace-Id=Root=1-5b96aec8-addec09261723342f53a179f, Content-Type=application/json}
Mon Sep 10 17:50:00 UTC 2018 : Successfully completed execution
Mon Sep 10 17:50:00 UTC 2018 : Method completed with status: 200
Run Code Online (Sandbox Code Playgroud)
tjusers您的DynamoDB 表的架构是什么?特别是, 的数据类型是什么badge?例如,如果它是数字,则需要使用"N"而不是"S"。
(总的来说,这是一个最近的新教程,可以满足您的要求,并且比我在其他教程中看到的更多详细信息/屏幕截图:https: //medium.com/@likhita507/using-api-gateway-to-get-data -来自-dynamo-db-using-without-using-aws-lambda-e51434a4f5a0 )
| 归档时间: |
|
| 查看次数: |
1298 次 |
| 最近记录: |