1
votes

I have configured API gateway as a Kinesis proxy as described in Amazon’s tutorial for putting record into Kinesis stream.

The HTTP headers for integration request are:

  • Content-Type is mapped to application/x-amz-json-1.1

The body mapping template for content-type application/json looks like:

#set($event =  "{
  ""rows"": ""$input.json('$')"",
 ""uuid"": ""$input.params('uuid')"",
}")
{
   "StreamName": "$input.params('stream-name')",  
   "Data": "$util.base64Encode($event)",  
   "PartitionKey": "$input.params('$partition-key')"
}

i am getting an internal server error when send a post request.

1

1 Answers

0
votes

Your body template mapping seems buggy.

If "PartitionKey" is part of request body use $input.path('$.PartitionKey') , for example when your request body is {"Data" : "example-data", "PartitionKey" : "example-key"}

;and if "partition-key" is part of api path(or query string, or header) use $input.params('partition-key') for example when your url is abc.api-xxxxx.com/{stream-name}/{parition-key}/{uuid}.

for more help in regards to input variable please refer to http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#input-variable-reference.

Thanks!