Can't receive duplicate query parameters

It’s pretty standard when encoding a list as GET parameters to duplicate the key for each entry of the list. This is, for instance, the default behaviour when calling an API via Retrofit in Java (see: https://square.github.io/retrofit/2.x/retrofit/) , or when submitting a form (see eg: http://stackoverflow.com/questions/2602043/rest-api-best-practice-how-to-accept-list-of-parameter-values-as-input)

However if I pass multiple identical query parameters to a Serverless Lambda, the event['queryStringParameter'] dictionary only contains the last key, so e.g. some_url?q[]=cat&q[]=dog ends up giving me {"q[]": "dog"} as the entire event['queryStringParameter'] .

This makes it impossible to build serverless APIs that ever have duplicated query parameters which seems unfortunate.

Have you tried not using the PHP-esque practice of putting [] on the field name?
It’s not at all part of the form specs.

I have some code that works using:

event['queryStringParameters']['tag']

for getting a list of tags to filter by.

1 Like