通过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 gateway fails to generate transformed request部分相关,但是这一部分讨论了请求。
最佳答案
关于json - Amazon API Gateway : response body is not transformed when the API is called via Postman?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39352240/