【问题标题】:Setting an empty GatewayResponse (just status code) in AWS API Gateway在 AWS API Gateway 中设置一个空的 GatewayResponse(只是状态码)
【发布时间】:2020-08-27 03:42:50
【问题描述】:

有没有办法在 Cloudformation 中为 API 网关设置 GatewayResponse,响应主体为空(最好没有响应 Content-Type)

我尝试过这样的事情:

  InvalidApiKeyResponse:
    Type: AWS::ApiGateway::GatewayResponse
    Properties:
      ResponseType: INVALID_API_KEY
      RestApiId: !Ref RestApi
      StatusCode: 403

但它仍然返回默认的应用程序/json 响应。

在 AWS 控制面板中,当我尝试设置空响应时,出现以下错误:Invalid null or empty value in responseTemplates

【问题讨论】:

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


    【解决方案1】:

    尝试添加下面的 ResponseTemplates。

    GatewayResponse:
        Type: AWS::ApiGateway::GatewayResponse
        Properties:
          ResponseTemplates:
              application/json: ""
          ResponseType: INVALID_API_KEY
          RestApiId: !Ref RestApi
          StatusCode: 403
    

    【讨论】:

      猜你喜欢
      • 2017-06-27
      • 2017-01-28
      • 1970-01-01
      • 2018-04-19
      • 1970-01-01
      • 2020-03-18
      • 2016-09-12
      • 2020-06-22
      • 2019-09-24
      相关资源
      最近更新 更多