【发布时间】:2023-03-17 05:21:01
【问题描述】:
有什么方法可以从 DynamoDB 中找出响应代码 400 的确切原因?在试验 DynamoDB 时遇到问题。我的主键是 Topic,PostedTimeStamp 是排序键,我在类别上创建了一个 LSI。以下是创建表的命令。
aws dynamodb create-table --debug --table-name Topics --attribute-definitions AttributeName=Topic,AttributeType=S AttributeName=PostedTimeStamp,AttributeType=S AttributeName=Category,AttributeType=S AttributeName=SubCategory,AttributeType=S --key-schema AttributeName=Topic,KeyType=HASH AttributeName=PostedTimeStamp,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5 --local-secondary-indexes IndexName=TopicCategory,KeySchema=["{AttributeName=Topic, KeyType=HASH}","{AttributeName=Category, KeyType=RANGE}"],Projection="{ProjectionType=KEYS_ONLY}" IndexName=TopicSubCategory,KeySchema=["{AttributeName=Topic,KeyType=HASH }","{AttributeName=SubCategory,KeyType=RANGE}"],Projection="{ProjectionType=KEYS_ONLY"}
以下是我尝试运行的查询。
{
"TableName": "Topics",
"IndexName": "TopicCategory",
"ConsistentRead": false,
"KeyConditionExpression": "Topic = :v1 and Category = :v2",
"ExpressionAttributeValues": {
":v1": {
"S": "DyanmoDB"
}
":v2": {
"S": "LSI"
}
}
}
收到以下响应...这对于许多错误很常见...例如 InvalidAction、InvalidParameterCombination、InvalidQueryParameter 等。
"Received response. Status: 400, Integration latency: 6 ms
【问题讨论】:
-
错误响应应该有一个 HTTP 状态代码(如 400)和一个错误消息。您是否记录了整个响应负载?
-
@Jarmod, Http 状态码是 200 (Ok), 这是内部响应码 400 表明 dynamoDB 无法运行查询并且无法正确返回结果,即使它收到了请求并返回响应。
-
您在哪里收到此错误?来自 CLI?locall dynamo?
-
@Alex,我正在尝试使用 APIGateway 代理查询 DyanameDB。谢谢
-
基本上我正在尝试做这里提到的事情......aws.amazon.com/blogs/compute/…
标签: amazon-web-services nosql amazon-dynamodb dynamodb-queries