Python – DynamoDB : The provided key element does not match the schema


Is there a way to get an item depending on a field that is not the hashkey?


My Table Users: id (HashKey), name, email

And I want to retrieve the user having email as ''

How this can be done?

I try this with boto:

user = users.get_item(email='')

I get the following error:

'The provided key element does not match the schema'

Best Answer

The following applies to the Node.js AWS SDK in the AWS Lambda environment:

This was a rough one for me. I ran into this problem when trying to use the getItem method. No matter what I tried I would continue to receive this error. I finally found a solution on the AWS forum:

Inexplicably, the apparent solution conflicts with all AWS documentation that I can find.

Here is the code which worked for me:

var doc = require('dynamodb-doc');
var dynamo = new doc.DynamoDB();

var params = { }
params.TableName = "ExampleTable";
var key = { "ExampleHashKey": "1" };
params.Key = key;

dynamo.getItem(params, function(err, data) {
    if (err)