【问题标题】:connect api gateway to kinesis stream将 api 网关连接到 kinesis 流
【发布时间】:2017-07-18 11:07:27
【问题描述】:

我已将 API 网关配置为 Kinesis 代理,如 Amazon 将记录放入 Kinesis 流的教程中所述。

集成请求的 HTTP 标头是:

  • Content-Type 映射到 application/x-amz-json-1.1

content-type application/json 的 body 映射模板如下:

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

发送发布请求时出现内部服务器错误。

【问题讨论】:

    标签: json amazon-web-services aws-api-gateway amazon-kinesis


    【解决方案1】:

    您的正文模板映射似乎有问题。

    如果“PartitionKey”是请求正文的一部分,请使用 $input.path('$.PartitionKey') ,例如当您的请求正文是 {"Data" : "example-data", "PartitionKey" : "example-key"}

    ;如果“partition-key”是 api 路径(或查询字符串或标头)的一部分,则使用 $input.params('partition-key'),例如当您的 url 为 abc.api-xxxxx.com/{stream-name}/{parition-key}/{uuid} 时。

    有关输入变量的更多帮助,请参阅http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#input-variable-reference

    谢谢!

    【讨论】:

      猜你喜欢
      • 2016-08-20
      • 1970-01-01
      • 2023-02-26
      • 1970-01-01
      • 2019-08-20
      • 2022-07-28
      • 1970-01-01
      • 2018-02-09
      • 1970-01-01
      相关资源
      最近更新 更多