Reputation: 566
I getting error below error in AWS Cloudformation:
Validation Result: warnings : [], errors : [Invalid content type specified: method.response.header.Content-Type] (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException;
rootProxy:
Type: 'AWS::ApiGateway::Method'
Properties:
ResourceId: !Ref rootResource
RestApiId: !Ref apigatewayRestApi
AuthorizationType: NONE
HttpMethod: ANY
RequestParameters:
method.request.header.Content-Type: false
method.request.path.proxy: false
Integration:
PassthroughBehavior: WHEN_NO_MATCH
RequestParameters:
integration.request.path.proxy: method.request.path.proxy
integration.request.header.Content-Type: method.request.header.Content-Type
IntegrationResponses:
-
StatusCode: 200
ResponseTemplates:
method.response.header.Content-Type: "integration.response.header.Content-Type"
Type: AWS
Credentials: "arn:aws:iam::xxx:user/[email protected]"
IntegrationHttpMethod: ANY
Uri: !Sub
- arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${SSRlambdaArn}/invocations
- SSRlambdaArn: !GetAtt SSR.Arn
MethodResponses:
-
StatusCode: 200
ResponseModels:
application/json: Empty
text/plain: Empty
ResponseParameters:
method.response.header.Content-Type: true
Any Idea on this error?
Upvotes: 0
Views: 1543
Reputation: 238239
For ResponseTemplates
you should specify Velocity Template Language code and correct Content-Type
for which the template belongs to.
So instead of:
IntegrationResponses:
-
StatusCode: 200
ResponseTemplates:
method.response.header.Content-Type: "integration.response.header.Content-Type"
You should have something like this (just an example; need to modify to your API):
ResponseTemplates:
application/json: |
#set($inputRoot = $input.path('$'))
[
#foreach($elem in $inputRoot)
{
"number": $elem.id,
"class": "$elem.type",
"salesPrice": $elem.price
}#if($foreach.hasNext),#end
#end
]
Or maybe you don't need it at all. Its application specific how, and if, to use the ResponseTemplates
.
Upvotes: 1