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 Antworten
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"
    }
AWS
EXPERTE
Parnab
beantwortet vor 2 Jahren
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 } }

AWS
beantwortet vor 2 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen