AWS API Gateway URL Query String Parameters With Square Bracket - amazon-web-services

I'm making a Passthrough API Gateway using Magento 2 API to search certain products (GET Method). In this document the parameters look like this:
searchCriteria[filter_groups][0][filters][0][field]:name
searchCriteria[filter_groups][0][filters][0][value]:%tea%
searchCriteria[filter_groups][0][filters][0][condition_type]:like
When i try the endpoint API URL that given to me, it works and the result looks like this:
Then I start to make the Passthrough API Gateway in AWS but unfortunately AWS API Gateway doesn't allow me to input square bracket([]) in the URL Query String Parameters with message warnings : [], errors : [Parameter name should match the following regular expression: ^[a-zA-Z0-9._$-]+$].
I tried to deploy the API Gateway without any URL Query String Parameters and the response is that parameter is required.

Related

AWS API Gateway expects the request URL to be encoded twice

My API is a request that can potentially have spaces in the pathParameters.
/data/{id}/hello/{Some message with a space}.
A sample request would be /data/23/hello/Say%20Hi
My angular code from the frontend encodes the request URL that is sent out to the AWS API Gateway but I get the following error.
`The Canonical String for this request should have been
'GET
/data/23/hello/Sayr%2520Hi`
My API gateway has a velocity template the decodes the parameters using $util.urlDecode()
I'm facing the same problem.
I've been stuck for a day.
If you are using HttpApi it cannot be solved.
Nevertheless, if you use RestApi I managed to make this work.
Specifically, you should use the URL Path Parameters.
You should:
Add a resource containing the /{variable}
Add a Url Path Parameter in the Integration Request Configuration with name variable and mapped from method.request.path.variable
Notice that the solution may depend on the integration type that you are using.
In the screenshot below you can see how I'm redirecting all the received traffic to a NetworkLoadBalancer.
The resource has the variable /{proxy+}, the endpoint URL has the {proxy}, and, in the URL Path Parameters, I've configured the mapping method.request.path.proxy.

Request validation on path in Api Gateway

I have an API gateway which is a kind of url shortner, it accepts all
the get requests and return the long url associated with that short
url path. example
input GET => xxx.com/abc
return => aaa.com/blablablabla
I want to implement some validation on this so that I don't get
unnecessary junk requests based on path with a regular expression
suppose path should start with "a" in incoming request xxx.com/abc
How can I do that via api gateway request validator, any help
You better try Lambda Authorizer for requests validator.
Your Lambda function will have 2 main tasks
Validate the URL of the request.
Validate the request's Auth header.
Lambda supports various of languages: Python3, Go, Java, Node.js ... so you are freely to use ReGex to filter your requests.
Reference: https://docs.aws.amazon.com/apigateway/latest/developerguide/configure-api-gateway-lambda-authorization-with-console.html

WS API Gateway Websockets HTTP Integration — Target URL rewrite from request body

I'm trying to dynamically change the integration request URL (http integration point) based on a value inside the body of the message
Lets say the message looks like this:
{"action": "something", "objectId": "2345werty"}
I would like my URL to be dependent of the $.objectId field from the request.
I have tried stuff like
https://${stageVariables.baseUrl}/resource/${request.body.objectId}
https://${stageVariables.baseUrl}/resource/$request.body.objectId
https://${stageVariables.baseUrl}/resource/${input.body.objectId}
https://${stageVariables.baseUrl}/resource/${method.request.body.objectId}
The stage variable works fine, but obtaining
I know this is supposed to be somehow possible with HTTP api gateway, but I haven't found a way to do it with the Websockets API Gateway.

Handle Space in AWS API Gateway API URL - I am using Dynamodb Proxy

I have a AWS API Gateway - and using dynamodb to read Data from database, its running good enough if I sent a parameter without Space.
URL Pattern: API_LINK/benchmark_performance/{benchmark}
if {benchmark} is replaced with a String with a space - AWS replies with no/blank data, No Error Reported. if the parameter doesn't have space in it then it sends data correctly. I also tried using JS URI_encoder method and send it but same result
If I test the AWS API End point from AWS console (parameter has Space), then the result is shown properly but the same URL gives no data when called from Browser or angular 2 Application.
Question: What should I do at AWS API Gateway Integration Mapping, that it gives me proper output and handles the space in parameter issue.
Got the answer : http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
I used :
$util.urlDecode() (Decodes an "application/x-www-form-urlencoded" string).
how to use =>
$util.urlDecode($.input.params('yourParameterName'))
in Integration Mapping (section) of API Gateway

How to pass through a query string parameter with square brackets in Amazon API Gateway

I want to use API Gateway as a caching proxy for an HTTP server, which in turn uses jsonapi-resources to define the API.
The issue is that jsonapi-resources requires query string parameters of the form ?page[number]=10&page[size]=10 to paginate results. However, if I try to add page[number] to URL Query String Parameters on a Method Request page, I receive the following error:
I've also tried to percent-encode the name as page%5Bnumber%5D without any success; the parameter is still filtered out.
Is there a way to make it work?
If you encode the [ by %5B, API Gateway doesn't allow % in the parameter name.
Currently, AWS API Gateway only supports the parameter name matches ^[a-zA-Z0-9._$-]+$
Does page.number work for you?