Reputation: 91
I am trying to update an item from my DynamoDb table from a AWS Lambda function and I am getting the following error:
"errorMessage": "An error occurred (ValidationException) when calling the UpdateItem operation: The provided key element does not match the schema",
I have not defined a sort key when defining my table, and my partition key is named 'pipeId', and I have used the following code:
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table('mytable')
response = table.update_item(
Key={
'pipeId': pipe_id
},
UpdateExpression="set hookId = :r",
ExpressionAttributeValues={
':r': hook_id
},
ReturnValues="UPDATED_NEW"
)
Isn't possible to get or update an item without previously setting a sort key ? or am I doing something wrong here ?
Upvotes: 1
Views: 3097
Reputation: 91
I have found the solution.
The problem was that my primary key is defined as number and I was inserting it as String, like "3219"; but it doesn't convert automatically.
Upvotes: 2