gpt4 book ai didi

php - 400 错误请求响应 : KeyConditionExpression parameter must be specified in the request

转载 作者:行者123 更新时间:2023-12-05 01:43:53 27 4
gpt4 key购买 nike

我正在尝试在我的 php 应用程序中使用 amazon dynamodb。我已正确设置凭据。现在,我正在尝试将数据从 Amazon DynamoDB 获取到我的应用程序。但它在查询行给了我一个异常(exception)。

完整的异常错误是

Unable to query: Error executing "Query" on "https://dynamodb.my-region.amazonaws.com"; AWS HTTP error: Client error: POST https://dynamodb.my-region.amazonaws.com resulted in a 400 Bad Request response: {"__type":"com.amazon.coral.validate#ValidationException","message":"Either the KeyConditions or KeyConditionExpression (truncated...) ValidationException (client): Either the KeyConditions or KeyConditionExpression parameter must be specified in the request. - {"__type":"com.amazon.coral.validate#ValidationException","message":"Either the KeyConditions or KeyConditionExpression parameter must be specified in the request."}

这是我的代码,

$sdk = new Aws\Sdk([
'region' => 'my region',
'version' => 'latest',
'credentials' => [
'key' => 'my key',
'secret' => 'my secret key'
],
'DynamoDb' => [
'region' => 'my region',
],
]);

$dynamodb = $sdk->createDynamoDb();
$marshaler = new Marshaler();

$tableName = 'My Table Name';

$params = [
'TableName' => $tableName
];

try {
$result = $dynamodb->query($params);
} catch (DynamoDbException $e) {
echo "Unable to query:\n";
echo $e->getMessage() . "\n";
}

错误来自 try-catch block 。任何人都可以告诉我这个错误的原因和解决方案吗?对这个错误有什么建议吗?提前致谢。

最佳答案

请添加带有值的KeyConditionExpression

 $params = [
'TableName' => $tableName,
'KeyConditionExpression' => 'yourHashKey = :v_hash'
'ExpressionAttributeValues' => array (
':v_hash' => array('S' => 'Hash_Value')
)
];

关于php - 400 错误请求响应 : KeyConditionExpression parameter must be specified in the request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48168007/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com