DynamoDB putItem Validation Error: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes
See original GitHub issueHere is my code:
obj = _.chain(obj)
.values()
.map(function(item) {
return item ? item.toString() : "";
})
.value();
DynamoDB.putItem({
"TableName": tblName,
"Item": {
"UserId": { "S": obj.user_id },
"Identifier": { "S": obj.identifier },
"ReferralToken": { "S": obj.referral_token },
"CampaignId": { "S": obj.campaign_id },
"FirstName": { "S": obj.first_name },
"LastName": { "S": obj.last_name },
"Gender": { "S": obj.gender },
"BirthDate": { "S": obj.birthdate },
"Username": { "S": obj.username },
"MobileNumber": { "S": obj.mobile_number },
"PostalCodeText": { "S": obj.postal_code_text },
"Classification": { "S": obj.classification },
"DeliveryEmail": { "S": obj.delivery_email },
"DeliverySMS": { "S": obj.delivery_sms }
}
}, function (err, data) {
console.log(err);
console.log(data);
});
The error I keep getting is:
{ [ValidationException: Supplied AttributeValue is empty, must contain exactly one of the supported datatypes]
message: 'Supplied AttributeValue is empty, must contain exactly one of the supported datatypes',
code: 'ValidationException',
time: Fri Oct 10 2014 11:04:00 GMT-0500 (CDT),
statusCode: 400,
retryable: false }
I am sure I am doing something obviously wrong, I just can’t seem to figure out what’s wrong
Issue Analytics
- State:
- Created 9 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Supplied AttributeValue is empty, must contain exactly one of ...
Attribute values cannot be null. String and Binary type attributes must have lengths greater than zero. Set type attributes cannot be empty.
Read more >Supplied AttributeValue is empty, must contain exactly one of ...
empty, must contain exactly one of the supported datatypes (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException;
Read more >Expected - Amazon DynamoDB - AWS Documentation
EQ is supported for all datatypes, including lists and maps. AttributeValueList can contain only one AttributeValue element of type String, Number, Binary, ...
Read more >DynamoDB putItem Validation Error - Bountysource
DynamoDB putItem Validation Error : Supplied AttributeValue is empty, must contain exactly one of the supported datatypes.
Read more >Supplied AttributeValue is empty, must contain exactly one of ...
iOS : ValidationException : Supplied AttributeValue is empty, must contain exactly one of the supported datatypes [ Beautify Your Computer ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@dennismonsewicz the DynamoDB API does not allow empty strings for items, see here (search for “empty string”). Your code that replaces items with “” is likely what is causing the error.
If you really want to store those empty objects, you might consider using the new
NULLtype in DynamoDB just released this week, though that would require passing (and parsing){ NULL: true }instead of{ S: ... }. You might also want to look at awslabs/dynamodb-document-js-sdk which supports converting null values in a more transparent way using the newNULLtypes.Thanks so much for the help! I think I figured out my issue.
It appears even if you label an item as an
Ntype, you have to convert it the item to a string. So your object mapping would look like…