I'm trying to insert data to DynamoDB directly with API Gateway. I can insert single, but get stuck with insert multiple data rows. May be problem with the mapping template (always get com.amazon.coral.service#SerializationException error)
- My dynamoDB table structure
ex_table: time, column1, column2 - My gateway mapping template:
#set($inputRoot = $input.json('$.items')})
{
"TableName": "ex_table",
"Item":
[
#foreach($elem in $inputRoot) {
"time": {"S": $input.json('$.time')},
"column1": "$elem.column1.S",
"column2": "$elem.column2.S",
}#if($foreach.hasNext),#end
#end
]
}
- And this is my request body:
{
"time": "2021-03-31 16:50:00",
"items": [
{
"column1": "Item1",
"column2": "Attr1"
},
{
"column1": "Item2",
"column2": "Attr2"
}
]
}
Can you guys help me this. Many thanks !