1

Im using a Lambda function to get and put data to DynamoDB.

I am able to put a new item into my table, but when I try to pass anything other than KEY I get the following error:

An error occurred (ValidationException) when calling the UpdateItem operation: 
The provided key element does not match the schema

This works (with key only):

"body": "{\"TableName\":\"myExampleTableName\",\"Key\":{\"id\": {\"S\": \"SomeID\"}}}"

This throws error(with key and some data):

"body": "{\"TableName\":\"myExampleTableName\",\"Key\":{\"id\": {\"S\": \"SomeID\"},\"Data\": {\"S\": \"MyDataExampleData\"}}}"

Although it seems to be the same syntax as the example shows here.

Anybody see what I am doing wrong?

Here's the my body in a more readable way:

{
    "TableName":"myExampleTableName",
    "Key":{
        "id": {"S": "SomeID"},
        "Data": {"S": "MyDataExampleData"}
    }
}
1
  • 1
    What sdk are you using? Commented Aug 10, 2020 at 23:39

1 Answer 1

1

The "Data" field inside the "Key" doesn't seem right. It would be easier to understand if we had the actual code and the schema of the table you're trying to put.

This is an example using python, where you can see that there's no "Key" attribute, but "Item" (I'm assuming you're using python based on the doc you've sent)

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GettingStarted.Python.03.html

response = table.put_item(
   Item={
        'year': year,
        'title': title,
        'info': {
            'plot': plot,
            'rating': rating
        }
    }
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.