通过 AWS API Gateway 控制台执行测试时,我发现 Lambda 函数的输出响应已正确转换:
{
"type" : "",
"message" : "",
"request-id" : ""
}
请参阅下面的日志:
Tue Sep 06 14:46:06 UTC 2016 : Endpoint request body after transformations: {}
Tue Sep 06 14:46:06 UTC 2016 : Endpoint response body before transformations: {"errorMessage":"501stef"}
Tue Sep 06 14:46:06 UTC 2016 : Endpoint response headers: {x-amzn-Remapped-Content-Length=0, x-amzn-RequestId=a4540f42-7440-11e6-90ce-214b29fcde38, Connection=keep-alive, Content-Length=26, Date=Tue, 06 Sep 2016 14:46:06 GMT, Content-Type=application/json}
Tue Sep 06 14:46:06 UTC 2016 : Method response body after transformations: {
"type" : "",
"message" : "",
"request-id" : ""
}
Tue Sep 06 14:46:06 UTC 2016 : Method response headers: {Content-Type=application/json}
Tue Sep 06 14:46:06 UTC 2016 : Successfully completed execution
Tue Sep 06 14:46:06 UTC 2016 : Method completed with status: 501
但是,当通过带有标头的 Postman 调用 API 时:
Content-Type : application/json
Accept : application/json
没有发生输出转换,输出 JSON 消息只是:
{
"errorMessage": "501stef"
}
部分相关Amazon APi 网关无法生成转换后的请求但这是关于Request.