When I try to create an API Gateway API with a proxy resource by using AWS CloudFormation or OpenAPI (Swagger), I get an error "Execution failed due to configuration error: Illegal character in path." How do I resolve this error?

Last updated: 2019-07-03

I'm using an AWS CloudFormation template or OpenAPI (Swagger) API definition to create an Amazon API Gateway API with a proxy resource. When I create the API, I get the error "Execution failed due to configuration error: Illegal character in path." How do I fix this?

Short Description

This error can occur if you don't define a URL path parameter mapping for the proxy path parameter {proxy+} (also called a "greedy path variable"). Without that mapping defined, API Gateway evaluates the parameter name as the literal string "{proxy+}". This causes an error, because "{" is not a valid character.

Resolution

  1. In the API Gateway console, choose the name of your API.
  2. With the method selected in the Resources pane, in the Method Execution pane, choose Integration Request.
  3. In the Integration Request pane, verify that the Endpoint URL uses the correct proxy path parameter: {proxy}. (That is, the greedy path variable without "+".) For example: http://example.com/{proxy}
  4. Expand URL Path Parameters, then choose Add path.
  5. Do the following:
    For Name, enter proxy. This corresponds to the parameter in the Endpoint URL.
    For Mapped from, enter method.request.path.proxy. Here, proxy corresponds to the name of the request path as defined in the Method Request pane.
  6. Choose the check mark icon (Create).
    Note: If you get the error "Invalid mapping expression specified," then update your AWS CloudFormation template or OpenAPI definition. After that, repeat the steps in this article.
  7. Deploy your API.