Closed dennismonsewicz closed 10 years ago
@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 NULL
type 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 new NULL
types.
Thanks so much for the help! I think I figured out my issue.
It appears even if you label an item as an N
type, you have to convert it the item to a string. So your object mapping would look like...
{ "N": "1234" }
@dennismonsewicz local parameter validation should have caught that one:
var params = {
TableName: 'table',
Item: { session_id: {S:'id'}, numericValue: {N:1234} }
};
dynamodb.putItem(params, function(err, data) {
if (err) console.log(err);
});
// prints:
// InvalidParameterType: Expected params.Item['numericValue'].N to be a string
Did you not get that error? If not, can you provide some code that got the service side error without parameter validation? Or do you have parameter validation disabled?
@dennismonsewicz I'm going to mark this as closed since it seems like you've resolved your issue. If you can chime in about the questions I asked above, that would be great!
@lsegal so sorry for the delay, been heads down on this project and forgot to chime back in.
Shouldn't declaring a value of N
be saved as Numeric type?
N: "1234" Always needs double quotations to be converted to a string. What I'm trying to figure out is if you change "N" to an event?
Example:
Change N: "1234" to N: event.something
Something being an attribute. That's when I get the error Supplied AttributeValue is empty,
Here is my code:
The error I keep getting is:
I am sure I am doing something obviously wrong, I just can't seem to figure out what's wrong