1

Is there a way to set a GatewayResponse for an API Gateway in Cloudformation, with an empty response body (and ideally without response Content-Type)

I have tried with something like this:

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

but it still returns the default application/json response.

In the AWS dashboard, when I try to set an empty response I get the following error: Invalid null or empty value in responseTemplates

1 Answer 1

1

Try adding in the ResponseTemplates piece below.

GatewayResponse:
    Type: AWS::ApiGateway::GatewayResponse
    Properties:
      ResponseTemplates:
          application/json: ""
      ResponseType: INVALID_API_KEY
      RestApiId: !Ref RestApi
      StatusCode: 403
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.