Reputation: 37
I am trying to retrieve a database item with the username key of my DB. I have the following PHP code:
$result = $DBclient->getItem(array(
"TableName" => $TableName,
"ConsistentRead" => true,
"Key" => array(
"username" => strtolower($_POST["username"])
)
));
After it runs, the following error occurs:
Fatal error: Uncaught Aws\DynamoDb\Exception\DynamoDbException: AWS Error Code: SerializationException, Status Code: 400, AWS Request ID: (...), AWS Error Type: client, AWS Error Message: Expected null, User-Agent: aws-sdk-php2/2.8.31 Guzzle/3.9.3 curl/7.51.0 PHP/5.6.30 thrown in (...)\vendor\aws\aws-sdk-php\src\Aws\Common\Exception\NamespaceExceptionFactory.php on line 91
My table has three keys (indexes, rows...) : username (S), password (S), and id (N)
I read the documentation but i think i'm missing something here.
Upvotes: 0
Views: 1065
Reputation: 3652
You need to specify the type of your Key
element and the value. You are missing the type.
So your code should be:
$result = $DBclient->getItem(array(
"TableName" => $TableName,
"ConsistentRead" => true,
"Key" => array(
"username" => array("S" => strtolower($_POST["username"]))
)
));
Upvotes: 1