Reputation: 3404
Not sure, what is the issue while get item from DynamoDB.
Json View of Data :
{
"section_id": "6177d23bb5f04ca363fe3d91",
"chapter_id": "6177ccd4b5f04ca363fe3d63",
"data": {
}
}
PHP Code :
$sdk = $this->sdk();
$dynamodb = $sdk->createDynamoDb();
$result = $dynamodb->getItem(
array(
'TableName' => 'sections',
'Key' => array(
'section_id' => array(
'S' => '6177d23bb5f04ca363fe3d91'
)
)
)
);
print_r($result);
exit;
Error I'm getting
Type: Aws\DynamoDb\Exception\DynamoDbException
Message: Error executing "GetItem" on "https://dynamodb.ap-south-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://dynamodb.ap-south-1.amazonaws.com` resulted in a `400 Bad Request` response: {"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema" (truncated...) ValidationException (client): The provided key element does not match the schema - {"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema"}
Upvotes: 1
Views: 204
Reputation: 4053
Considering the error, There could be two possible problems here:
Upvotes: 2
Reputation: 1203
The error message tells the problem: "The provided key element does not match the schema"
Is section_id your primary key? If so, you can try it like this:
$result = $dynamodb->getItem(
[
'TableName' => 'sections',
'Key' => [
'section_id' => ['S' => '6177d23bb5f04ca363fe3d91'],
],
]
);
You are providing an array to a GetItem call but you need to provide a primary key.
See: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html
Upvotes: 0