By using AWS re:Post, you agree to the Terms of Use
/Step function putItem DynamoDB/

Step function putItem DynamoDB

0

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

2 Answers
0

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"
    }
EXPERT
answered 3 months ago
0

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 } }

answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions