POST to DynamoDB for user login getting.
Fatal error: Uncaught exception 'Aws\DynamoDb\Exception\DynamoDbException' with message 'Error executing "GetItem" on "https://dynamodb.us-east-1.amazonaws.com"; AWS HTTP error: Client error:
POST https://dynamodb.us-east-1.amazonaws.com
resulted in a400 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"}' GuzzleHttp\Exception\ClientException: Client error:POST https://dynamodb.us-east-1.amazonaws.com
resulted in a400 Bad Request
response: {"__type":"com.amazon.coral.validate#ValidationException","message":"The provided key element does not match the schema" (truncated...) in /var/www/html/sdks/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 Stack trace: #0 /var/www/html/sdks/vendor/guzz in /var/www/html/sdks/vendor/aws/aws-sdk-php/src/WrappedHttpHandler.php on line 192
MY PHP Code -----
require 'config.php';
use Aws\DynamoDb\DynamoDbClient;
$client = new DynamoDbClient([
//'profile' => 'default', // access ID + secret are in the .aws/credentials file
'region' => 'us-east-1', // also tried with "eu-west-1"
'version' => 'latest',
'debug' => true
]);
// echo "after client instanciation"; // this is not displayed
$username = null;
$password = null;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if(!empty($_POST["userid"]) && !empty($_POST["password"])) {
$username = $_POST["userid"];
$password = $_POST["password"];
$response = $client->getItem(array(
'TableName' => 'user',
'Key' => array(
'userid' => array( 'S' => $username),
'password' => array( 'S' => $password),
)
));
if($username == 'userid' && $password == 'password') {
session_start();
$_SESSION["authenticated"] = 'true';
header('Location: index.php');
}
//else {
//header('Location: login.php');
//}
//} else {
//header('Location: login.php');
}
print_r ($response['Item']);
}
?>