a-sak
a-sak

Reputation: 1340

DynamoDB simple UpdateItem throwing "The provided key element does not match the schema" ValidationException

I'm trying to update a string field in a DynamoDB table (thread1) which only has Hashkey(threadId). Document with threadId = "AA" definitely exists and also has field1 attribute.

I'm getting "The provided key element does not match the schema" ValidationException when POST of UpdateItem from API Gateway is invoked using the following Body Mapping Template.

{
  "TableName": "thread1",
  "Key": {
    "HashKeyElement": {
      "S": "AA"
    }
  },
  "AttributeUpdates": {
    "field1": {
      "Value": {
        "S": "Worked!"
      }
    }
  }
}

I have also tried the same using UpdateExpression, which also gives the same error.

Upvotes: 3

Views: 6916

Answers (1)

jens walter
jens walter

Reputation: 14029

If your hashkey column is called 'threadId', your update should look like this:

{
  "TableName": "thread1",
  "Key": {
    "threadId": "AA"
  },
  "AttributeUpdates": {
    "field1": {
      "Value": "Worked!"
    }
  }
}

Upvotes: 3

Related Questions