Reputation: 51
I am integrating Kinesis Stream with API Gateway following this tutorial.
The records
endpoint uses the PutRecords
action. The expected request template for this endpoint is the following:
{
"StreamName": "$input.params('stream-name')",
"Records": [
{
"Data": "$util.base64Encode($elem.data)",
"PartitionKey": "$input.path('$.PartitionKey')"
}#if($foreach.hasNext),#end
]
}
Despite following the tutorial exactly as it is, if I send a Request body with the expected format such as the next one, I get a SerializationException
error:
{
"StreamName": "my_kinesis_stream",
"Records": [
{
"Data": "XzxkYXRhPl8x",
"PartitionKey": "partitionKey1"
},
{
"Data": "f1PxFQo92Afh",
"PartitionKey": "partitionKey1"
},
{
"Data": "Gi4sEdd08HypA",
"PartitionKey": "partitionKey1"
}
]
}
I don't know if the template of the tutorial is the right one or if my body request has not the proper format.
Oddly, all the other endpoints of the tutorial work just fine. This is the only one not working properly.
Thanks in advance.
Upvotes: 0
Views: 978
Reputation: 51
The documentation actually was wrong. This documentation specifies the correct request template:
{
"StreamName": "$input.params('stream-name')",
"Records": [
#foreach($elem in $input.path('$.records'))
{
"Data": "$util.base64Encode($elem.data)",
"PartitionKey": "$elem.partition-key"
}#if($foreach.hasNext),#end
#end
]
}
Upvotes: 0