Skip to content

Issue with slashes for Integrating API Gateway with CloudSearch

1

I am currently facing an issue while trying to integrate AWS API Gateway with CloudSearch. I have followed the official documentation to perform the integration.

The problem arises when my backend service sends requests with a slash in query parameters to the API Gateway, which are then sent to CloudSearch.

Here's an example:

Backend service sends: pretty%3Dtrue%26fq%3Dsectors%3A%27One%2FTwo%27%26q%3Dmatchall%26q.parser%3Dstructured

API Gateway decodes it to: pretty=true&fq=sectors:'One/Two'&q=matchall&q.parser=structured

Then, it sends to CloudSearch: q=matchall&pretty=true&q.parser=structured&fq=sectors:'One/Two'

Unfortunately, the slash in the request is no longer encoded when it reaches CloudSearch, which results in a 404 NOT Found error. I have tried different encodings for slash and tried to find some settings in API Gateway that could help.

I have also found a similar unresolved thread here: link

I would appreciate any insights or suggestions on how to resolve this issue. Is there a way to force API Gateway not to decode parameters, or to make CloudSearch expect decoded parameters? Many thanks for considering my request.

1 Answer
0

Hi,

You may want to try the double encoding technique for URL to still be in encoded form after passing through the API Gateway decoding: see https://owasp.org/www-community/Double_Encoding

As explained in the linked page, It's usually used by hackers. But, I guess that it is not your intent here! ;-)

Best,

Didier

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • I have tried to pass encoded and double-encoded values to the API gateway and I have also been attempting to hardcode query values in mapping templates, just to see if it works. All attempts are unsuccessful. If I pass the encoded value to API Gateway through the Test tab Input: pretty=true&fq=sectors:'One%2FTwo'&q=matchall&q.parser=structured Output: q=matchall&q.parser=structured&pretty=true&fq=sectors:'One%252FTwo' Same for double encoded and if I hardcode query values in mapping templates

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.