【问题标题】:"Unable to parse HTTP response content" when creating ApiGateway::Resource创建 ApiGateway::Resource 时“无法解析 HTTP 响应内容”
【发布时间】:2016-09-05 09:02:53
【问题描述】:

当我尝试创建 API Gateway-> GET 方法并使用 AWS CloudFormation 集成到 Lambda 函数时,我收到错误:
CREATE_FAILED AWS::ApiGateway::Resource [my resource] Unable to parse HTTP response content

有什么想法吗?!

【问题讨论】:

    标签: amazon-web-services aws-lambda amazon-cloudformation


    【解决方案1】:

    在指定 MethodResponses 时,强制包含状态代码。

    这将失败并显示“无法解析”:

    "MethodResponses": [{
      "ResponseModels": {
        "application/json": { "Ref": "myModel" }
    } } ],
    

    这会成功:

    "MethodResponses": [{
      "ResponseModels": {
        "application/json": { "Ref": "myModel" }
      },
      "StatusCode": 200 
    } ],
    

    不,the documentation 没有这么说。也没有举例。

    【讨论】:

    • 谢谢!它没有解决我的问题,所以我用 swagger 文件来描述我的 API 网关,现在一切正常。
    【解决方案2】:

    我遇到了这个问题,发现最终 CloudFormation 设计器中似乎有一个怪癖,它不断删除我的资源的 parentId。

    在上传之前检查您的云形成模板并确认 ParentId 仍在资源定义中。

    "myApiResource": { "Type": "AWS::ApiGateway::Resource", "Properties": { "RestApiId": { "Ref": "myRestApi" }, "PathPart": "mypath", "ParentId": { "Fn::GetAtt": [ "myRestApi", "RootResourceId" ] } },

    【讨论】:

    • 谢谢!看起来你是对的,CloudFormation 设计师从我的资源中删除了 parentId,我再次添加它,现在它正在工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-29
    • 1970-01-01
    • 2021-12-09
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多