I am trying to do a put item on a Dynamo Table using the nodejs sdk. I tried using the same document and a few other variations but nothing seems to work. Everytime I receive the same error:
"message":"Invalid attribute value type"
"code":"ValidationException"
"time":"2016-10-11T06:32:26.361Z"
"statusCode":400
"retryable":false
The following is the relevant code snippet:
var params = {
TableName: "MY_Table_Name",
Item: {
"stringAtt": "stringValue",
"boolAtt": true,
"numAtt": 123,
},
};
docClient.put(params, function(err, data) {
if (err) ppJson(err); // an error occurred
else ppJson(data); // successful response
});
My table's indexes are as follows:
Primary: Partition Key: stringAtt, Sort Key: boolAtt
GSI: Partition Key: boolAtt, Sort Key: numAtt
I am not sure if it's my query or the index structure that is wrong.
The BOOL data type can't be a key attribute (i.e. Partition or Sort key). The Partition or Sort key data type can be of three types (listed below). If you have created the table with Sort key of type 'B', it means that sort key is of type Binary (i.e. not Bool).
EDIT: You can't use a BOOL attribute as the partition or sort key in a GSI as well.
AttributeType: 'S | N | B'
S - the attribute is of type String
N - the attribute is of type Number
B - the attribute is of type Binary
When the table is created with key of type BOOL, the API would throw the below exception.
Unable to create table. Error JSON: {
"message": "Member must satisfy enum value set: [B, N, S]",
"code": "ValidationException",
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With