I'm trying to setup an API Gateway in front of my existing setup. Whenever I try to add an endpoint with a parameter, I get an error.
Invalid mapping expression specified: Validation Result: warnings : [], errors : [Invalid mapping expression parameter specified: method.request.querystring.type]
Here are screenshots:
What am I doing wrong?
I had the same problem too. This is what you need to do:
BTW: /number
is not a part of this example
Method Request
on the Method Execution
pageURL Query String Parameters
. You can set some params to be Required
as well.Return to the Method Execution
screen (see image num 1) and now click on Integration Request
Now you can see/set (in my case it was created automatically) your params under URL Query String Parameters
. If not, you can define them as you see in the picture.
After you finish all, click on Actions
and Deploy API
.
You can get your Invoke URL
under the Stages
tab on the left menu.
For more information, you can see this page (AWS docs) it has good explanation about this process. Hope it helps :)
In order to create a Path Parameter (which is a different concept than a query string) you create a resource with brackets, like in {your-parameter-name}
.
➡️ Path Paremeter: http://example.com/products/{id}/...
A query string appends to the end of the URL like in ?value=123
The console actually gives a description tip on how to do it:
You can add path parameters using brackets. For example, the resource path {username} represents a path parameter called 'username'. Configuring /{proxy+} as a proxy resource catches all requests to its sub-resources.
Here's how to do it:
/products
{product}
. This is the path parameter.https://dummyjson.com/products/{product}
. The console will help you with the suggestions and validation.That's it. You can now test your API method in the console and see that everything is routed to the target endpoint, including the path parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With