Kinesis Firehose HTTP_Endpoint 目标响应格式

Kinesis Firehose HTTP_Endpoint destination Response format

以 http_endpoint 作为目标的 Kinesis Firehose 响应的正确格式是什么。已经通过aws link: https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html#responseformat

我在 python(集成在 api 中)以及许多其他选项中使用了以下 lambda 代码,但不断收到以下错误消息。使用“使用演示数据测试”选项执行测试

示例代码:

def lambda_handler(event, context):
    data ={}
    headersD = {}
    
    headersD['content-length'] = 0
    headersD['content-type'] = 'application/json'
    data['requestId'] = 'ed4acda5-034f-9f42-bba1-f29aea6d7d8f'
    data['timestamp'] = '1578090903599'
    bodyDetail= {}
    data['body'] = ''
    data['headers'] =headersD
    data['statusCode']=200
    resp = json.dumps(data)
    return resp

日志中显示的错误响应:

从端点收到的响应无效。有关详细信息,请参阅 Firehose 文档中的 HTTP 端点故障排除。原因:。请求 'request-Id' 的响应未被识别为有效 JSON 或包含意外字段。收到原始回复:200“HttpEndpoint.InvalidResponseFromDestination”

这是有效的示例输出(在 python 中):

    
responseBody = {
    "requestId": "requestId",
    "timestamp": 123456
}
resp = {
"headers": {"Content-Type": "application/json", "Content-Length": 100},
"body": json.dumps(responseBody),
"statusCode": 200
}

return resp