gpt4 book ai didi

amazon-web-services - AWS Cloudformation 上的 Content-Type 出现错误

转载 作者:行者123 更新时间:2023-12-03 07:35:06 25 4
gpt4 key购买 nike

我在 AWS Cloudformation 中收到以下错误:

验证结果:警告:[],错误:[指定的内容类型无效:method.response.header.Content-Type](服务:AmazonApiGateway;状态代码:400;错误代码: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/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7a1b16133a02020254191517" rel="noreferrer noopener nofollow">[email protected]</a>"
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

对这个错误有什么想法吗?

最佳答案

对于 ResponseTemplates,您应该指定 Velocity 模板语言代码和模板所属的正确 Content-Type

所以代替:

        IntegrationResponses:
-
StatusCode: 200
ResponseTemplates:
method.response.header.Content-Type: "integration.response.header.Content-Type"

你应该有这样的东西(只是一个例子;需要修改你的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
]

或者也许您根本不需要它。其特定于应用程序如何以及是否使用ResponseTemplates

关于amazon-web-services - AWS Cloudformation 上的 Content-Type 出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63005560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com