0
votes

I have an API in AWS API Gateway that forwards the requests to another HTTP endpoint. I know I can map the query string parameters in "Integration Request". But I want to forward the value of a parameter as part of the path to the other endpoint. For example, let's say a call to my API is:

https://40gwfw20bg.execute-api.eu-west-1.amazonaws.com/beta?id=1234

I want the gateway to call the other endpoint passing the value of id in the path:

http://external.api.com/1234

Is that possible?

1

1 Answers

1
votes

Yes, this is very similar to this question

While you can use a Lambda function for this, you can also do it directly from API Gateway using basic request mapping.

Define your API in API Gateway and go to the root resource.

Add a GET method.

In the Method Execution pane, choose Method Request. Expand "URL Query String Parameters" Hit "Add query string" Type id as the name and hit the checkbox on the right to save.

Go back to the Method Execution pane, choose Integration Request. Edit your endpoint URL to add the path parameter, if you have not already done so. The URL should be: http://external.api.com/{id}

Choose the arrow next to "URL Path Parameters" to expand that section. Click "Add path". Enter id as the name Under "Mapped from" enter: method.request.querystring.id Click the check box on the right to save.

Go back to Method Execution and click Test. Add an id value under query strings and click test.

There are some similar examples in the documentation here