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 Respuestas
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
EXPERTO
Parnab
respondido hace 2 años
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
respondido hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas