How do I resolve "Execution failed due to configuration error: Illegal character in path" errors when creating an API Gateway API with a proxy resource?

Last updated: 2021-10-06

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

Short description

If a URL path parameter mapping for the proxy path parameter ({proxy+}) isn't defined, then API Gateway returns the following error:

Execution failed due to configuration error: Illegal character in path

Without a URL path parameter mapping defined for this parameter in the integration request, API Gateway evaluates the parameter as the literal string "{proxy+}". Because "{" isn't a valid character, API Gateway returns an error when this happens.

To resolve the error, define the URL path parameter mapping for the proxy path parameter in the integration request by doing the following:

Resolution

1.    In the API Gateway console, choose the name of your API.

2.    With the method selected in the Resources pane, choose Integration Request in the Method Execution pane.

3.    In the Integration Request pane, verify that the Endpoint URL uses the correct proxy path parameter: {proxy}. (The greedy path variable without "+".) For example: http://example.com/{proxy}

4.    Expand URL Path Parameters. Then, choose Add path and do the following:
For Name, enter proxy. This corresponds to the parameter in the Endpoint URL.
For Mapped from, enter method.request.path.proxy.
Note: Here, proxy corresponds to the name of the request path as defined in the Method Request pane. This request path is added by creating a proxy resource named {proxy} or, for a greedy path variable, {proxy+}.

5.    Choose the check mark icon (Create).

Note: If you get an Invalid mapping expression specified error, update your AWS CloudFormation template or OpenAPI definition. Then, repeat the steps in this article.

6.    Deploy your API.