0

In this question How to pass a querystring or route parameter to AWS Lambda from Amazon API Gateway

it shows how to map query string params to AWS lambda using API gateway. But, i want to pass a querystring inside a variable to lambda

For example: /api/index&sample=index.php <--- I want this to store in 'url'

www.sample.com/prod?url=/api/index&sample=index.php <--- Like this

but 'url' only returns /api/index

sample=index.php is treated as another variable.

I used application/json on mapping templates

{
    "url": "$input.params('url')"
}

How do you do this. Please help thanks in advance

leokkin6
  • 13
  • 4
  • As a test, change the URL to `www.example.com/prod?url=/api/index%26sample=index.php` and see what you get. – Michael - sqlbot Sep 12 '19 at 00:13
  • By URL encoding it will escape the '&', but by any chance is it possible to treat it as a whole string? like "/api/index&sample=index.php" (this does not work of course) – leokkin6 Sep 12 '19 at 17:20
  • I didn't realize you were familar with URL encoding. Values in a query string that cause ambiguity or are forbidden are required to be escaped. If I want to set the key `foo` to the value `bar&baz` in a query string, it's a violation of RFC-3986 to send it on the wire `foo=bar&baz` instead of as `foo=bar%26baz`... so your question, indirectly, is asking how to cause API Gateway to *incorrectly* tokenize the query string. The problem, I would suggest, is that the client is not following the standards. – Michael - sqlbot Sep 12 '19 at 17:34
  • Thanks for the enlightenment of this RFC-3986 standards – leokkin6 Sep 12 '19 at 18:38

0 Answers0