amazon-web-servicesamazon-gateway

How to create an endpoint with 2 path params. AWS API Gateway


I have an url in such format: resource_1/{id_1}/resource_2/{id_2}/assign.

I know how to create a simple proxy resource with 1 path param. But in my case I got two.

So I decided to create it one by one, at first resource_1/{id_1}/ and then expand it to resource_2/{id_2}/assign and as you see on picture, action Create Resourcce is blocked on initial proxy resource.

How can I solve this issue to have endpoint with 2 path params?

enter image description here


Solution

  • This is because your id+ is a proxy resource, as indicated by the + sign.

    From the doc :

    API Gateway defines a proxy resource as a placeholder for a resource to be specified when the request is submitted. A proxy resource is expressed by a special path parameter of {proxy+}, often referred to as a greedy path parameter. The + sign indicates whichever child resources are appended to it. The /parent/{proxy+} placeholder stands for any resource matching the path pattern of /parent/*. The greedy path parameter name, proxy, can be replaced by another string in the same way you treat a regular path parameter name.

    Remove the + sign from your parameter name and you will be allowed to create sub resources.