Jaky Chane
Jaky Chane

Reputation: 85

Update element in DynamoDB from API Gateway AWS

I'm requesting and managing a dynamoDb from the AmzonWebService.

I would update my element with new datas.

This is how I do :

  {
"TableName": "Strips",
  "Key": {
        "StripId": {
            "S": "$input.path('$.StripId')"
        }
    },
    "UpdateExpression": "set SessionId =  "$input.path('$.SessionId')"
    "ReturnValues": "ALL_NEW"
}

I have this error message and my element on my DB is not updated.

endpoint response body before transformations: {"__type":"com.amazon.coral.service#SerializationException"}

EDIT: This is the objet I'm using in my request body :

{
"StripId":"f58b6811-5a11-4a53-84d3-19bf42dd8fef",
"SessionId":"9fc6f591-e805-4113-b673-d596736b2ff3"
}

Does anyone know why ?

Upvotes: 0

Views: 1788

Answers (1)

notionquest
notionquest

Reputation: 39186

Please use the below:-

I have added ExpressionAttributeValues to provide value for SessionId.

{
  "TableName": "Strips",
  "Key": {
        "StripId": {
            "S": "$input.path('$.StripId')"
        }
    },
    "UpdateExpression": "set SessionId =  :sessionIdVal"
    "ExpressionAttributeValues" : {
        ":sessionIdVal": $input.path('$.SessionId'),
    },
    "ReturnValues": "ALL_NEW"
}

Upvotes: 1

Related Questions