Aws-cli: aws apigateway put-integration-response:不接受“null”的响应模板值

创建于 2015-10-31  ·  3评论  ·  资料来源: aws/aws-cli

在响应模板中指定null ,如下所示:

aws apigateway put-integration-response \
  --region "$region" \
  --rest-api-id "$api_id" \
  --resource-id "$resource_id" \
  --http-method GET \
  --status-code 200 \
  --response-templates '{"application/json":null}'

导致错误:

Parameter validation failed:
Invalid type for parameter responseTemplates.application/json, value: None, type: <type 'NoneType'>, valid types: <type 'basestring'>

如果我用null "Empty"接受参数:

  --response-templates '{"application/json":"Empty"}'

当 AWS 控制台创建相同的方法并查询它时,该值显示为null 。 看来我应该能够通过 aws-cli 将其设置为相同的值。

aws-cli/v1.9.2

guidance

最有用的评论

解决方法是传递空字符串而不是null ,即--response-templates '{"application/json":""}' ,你会得到

{
    "statusCode": "200",
    "responseTemplates": {
        "application/json": null
    }
}

所有3条评论

解决方法是传递空字符串而不是null ,即--response-templates '{"application/json":""}' ,你会得到

{
    "statusCode": "200",
    "responseTemplates": {
        "application/json": null
    }
}

谢谢。

谢谢@quiver@ehammond 。 恐怕“解决方法”实际上是正确的方法。 事实上,apigateway 服务被建模为期望字符串作为输入,因此所有 AWS 开发工具包都以这种方式工作,并且 apigateway 似乎在后台将空字符串转换为 null。 据推测,同样的故事也发生在 AWS 控制台中。

此页面是否有帮助?
0 / 5 - 0 等级