在响应模板中指定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
解决方法是传递空字符串而不是null
,即--response-templates '{"application/json":""}'
,你会得到
{
"statusCode": "200",
"responseTemplates": {
"application/json": null
}
}
谢谢。
谢谢@quiver和@ehammond 。 恐怕“解决方法”实际上是正确的方法。 事实上,apigateway 服务被建模为期望字符串作为输入,因此所有 AWS 开发工具包都以这种方式工作,并且 apigateway 似乎在后台将空字符串转换为 null。 据推测,同样的故事也发生在 AWS 控制台中。
最有用的评论
解决方法是传递空字符串而不是
null
,即--response-templates '{"application/json":""}'
,你会得到