Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS APIGateway集成响应映射模板无法根据内容类型正确切换_Amazon Web Services_Amazon S3_Aws Api Gateway_Integration - Fatal编程技术网

Amazon web services AWS APIGateway集成响应映射模板无法根据内容类型正确切换

Amazon web services AWS APIGateway集成响应映射模板无法根据内容类型正确切换,amazon-web-services,amazon-s3,aws-api-gateway,integration,Amazon Web Services,Amazon S3,Aws Api Gateway,Integration,我正在试验AWS API网关与S3后端的集成。我注意到集成响应中不同映射模板之间的切换似乎不起作用 在集成响应中,我有以下映射模板: 应用程序/json: { type: "JSON", body: "$input.body" } PlainText: $input.body 文本/纯文本: { type: "JSON", body: "$input.body" } PlainText: $in

我正在试验AWS API网关与S3后端的集成。我注意到集成响应中不同映射模板之间的切换似乎不起作用

在集成响应中,我有以下映射模板:

应用程序/json:

{
  type: "JSON",
  body: "$input.body"
}
PlainText:
$input.body
文本/纯文本:

{
  type: "JSON",
  body: "$input.body"
}
PlainText:
$input.body
我无能为力,似乎无法使用
text/plain
映射模板-它始终使用
application/json

我希望使用
text/plain
映射模板时基于以下情况之一:

  • S3返回内容类型为text/plain的内容
  • 对API网关的初始请求传递一个
    Accept:text/plain
  • 根据下面的示例,S3返回
    内容类型:text/plain
    ,我请求
    Accept:text/plain
    。API网关也正确响应
    内容类型:text/plain
    。 但是,
    application/json
    模板仍然用于转换主体

    我甚至将
    application/json
    作为有效的响应类型从方法响应中完全删除,但仍然没有

    你知道为什么会这样吗

    仅供参考,我使用的是经典的v1 ApiGateway(Rest)


    AWS支持人员向我确认,该开关基于原始请求
    Accept
    标题。使用Postman测试此功能可确认此功能

    但是,AWS控制台中内置的API网关测试工具似乎不适合测试响应映射模板——来自AWS支持:
    API网关测试控制台的目的只是测试集成,它不适用于端到端请求