Step function putItem DynamoDB
Hi, I'm using step function with task DynamoDB:PutItem. When Step function try to save the JSON
{
"TableName": "Table_Name",
"Item": {
"orderId": "159844346634674",
"mail": "test@test.com",
"itemId": "876434",
"channel": "Retail",
"createdDate": 1234512345
}
It receive the following error:
could not be used to start the Task: Cannot construct instance of com.amazonaws.services.dynamodbv2.model.AttributeValue
(although at least one Creator exists): no int/Int-argument constructor/factory method to deserialize from Number value (1234512345)
The field createdDate into DynamoDB have type "N".
Do you have any suggestion to fix this issue?
Thanks
Hi, DynamoDB expects the value of 'N' to be a string. You can read more about how DynamoDB handles numeric data in the Low-Level API docs here: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Programming.LowLevelAPI.html#Programming.LowLevelAPI.Numbers
If you use the following, the task should succeed:
{
"TableName": "Table_Name",
"Item": {
"orderId": "159844346634674",
"mail": "test@test.com",
"itemId": "876434",
"channel": "Retail",
"createdDate": "1234512345"
}
The error means that that there is no method to serialize the String in request to a number
Can you change the json to the one below and check again?
{ "TableName": "Table_Name", "Item": { "orderId": "159844346634674", "mail": "test@test.com", "itemId": "876434", "channel": "Retail", "createdDate": { "N": 1234512345 } }
Relevant questions
AWS Step Function Output for container services
asked 16 days agoError, AWS Step Function DynamoDB Put Item, Map and List inside Map
asked 5 months agoStep function putItem DynamoDB
asked 3 months agoInsufficient privilege when running AWS Backup from Step Function
Accepted Answerasked 2 months agoStep Function - dynamodb query with Boolean Filter
Accepted Answerasked 4 months agoInvalid security token error when executing nested step function on Step Functions Local
asked 12 days agoTrigger Step Function with API Gateway and use Fargate within Step Function?
asked 2 months agoStep Function Retry Metrics
asked 3 months agoStep Function to Send Email on Error/Success
asked 4 months agoStep Function error handling
asked 2 months ago