Aws-cli: aws apigateway put-integration-response: response-templates value of `null` not accepted

Created on 31 Oct 2015  路  3Comments  路  Source: aws/aws-cli

Specifying null in the response template as follows:

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}'

results in the error:

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

If I replace null with "Empty" the cli accepts the parameter:

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

When the AWS Console creates the same method and I query it, the value is shown as null. It seems like I should be able to set it to the same value through the aws-cli.

aws-cli/v1.9.2

guidance

Most helpful comment

Workaround is passing empty string instead of null, i.e. --response-templates '{"application/json":""}', and you'll get

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

All 3 comments

Workaround is passing empty string instead of null, i.e. --response-templates '{"application/json":""}', and you'll get

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

Thanks.

Thanks @quiver and @ehammond . I'm afraid that "workaround" is actually the correct way to do it. The fact is that the apigateway service is modeled as expecting a string as input, so all AWS SDKs work this way, and apigateway seemingly translates the empty string as null under the hood. Presumably, same story happens in AWS Console too.

Was this page helpful?
0 / 5 - 0 ratings