9

Is it possible to access the raw url using AWS API Gateway (and Lambda)?

Alternatively, is it possible to access the original, undecoded query string paramters?

We are integrating against a third party service, that calls our API and encodes the query string params from Windows-1252. (E.g. the finnish letter Ä is encoded as %C4 instead of %C3%84). API Gateway seems to automatically decode the query string parameters and assume UTF-8, which means, that Ä (and Ö and Å) result in \ufffd.

For reference: https://www.w3schools.com/tags/ref_urlencode.asp

5
  • I think not. ApiGateway by default decode all query parameters. But you can alway encode them back if you like Commented Oct 17, 2018 at 1:50
  • 2
    The problem is, I can not encode them back, because all non-ascii characters result in \ufffd (replacement character used when the decoding fails.) Commented Oct 17, 2018 at 6:42
  • Did you try adjusting your template mapping like this? stackoverflow.com/a/33143297/383839 Commented Oct 25, 2018 at 15:38
  • Is there something special about that approach? I did try creating the mapping myself, but when iterating $input.params().querystring the values are already decoded. Commented Oct 26, 2018 at 11:48
  • Similar question: stackoverflow.com/questions/49372722/… Commented Sep 6, 2019 at 18:01

1 Answer 1

7
+50

Damn, it really doesn't look possible...

I started off writing how you can use Lambda Proxy Integration with event.queryStringParameters, but that parses the data into a key-value object.

Then I went down the road of Mapping Templates in API Gateway, but again there doesn't seem to be any property that shows the whole querystring.

As much as I didn't want it to be true, I can only conclude that it is not possible...

I think your best option is to encode the parameter as base64 on the client, then decode in the Lambda function using Object.keys(event.queryStringParameters)[0].

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for trying to investigate this, even though it wasn't the answer I was hoping for. I really don't understand, why don't they pass on the raw url to be processed as you please...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.