2

I am trying to use AWS API Gateway to another service as follow:

https://jsonplaceholder.typicode.com/comments?postId=1&postId=2

I followed Map Request Parameters for an API Gateway API to create the get method.

So I have the following in method execution:

enter image description here

So as you can see I have a query param called id.

In integration I have:

enter image description here

So I map the id to postId and when I try the link just with one queryparam it works but when I try something like this:

url?id=1?postId=1&postId=2

How can I make the above scenario work with 2 query param?

Hamed Minaee
  • 2,480
  • 4
  • 35
  • 63

2 Answers2

2

My answer will be: Amazon API Gateway does not support multiple query string parameters with the same name.

I've played around with multiple parameters with the same name and it appears that API Gateway does not support such thing.

I was able to supply multiple 'id' parameters, but they were mapped into single latest value as you can see on screens below.

Multiple parameters

Log

I've even tried proxy method, then parameters are sent "as is", but even here Amazon process query string and aggregates query parameters with same name into one, with latest value specified.

Sergei B.
  • 3,227
  • 19
  • 18
  • Thanks a lot for clearing the issue. But is not a bug or weakness ? because due to the rest API sending parameters that way is an acceptable approach – Hamed Minaee May 27 '17 at 13:21
  • There is no standard which describes this case. Therefore I can say, it is definitely not a bug. Check the following link to see other opinions of the topic: https://stackoverflow.com/questions/24059773/correct-way-to-pass-multiple-values-for-same-parameter-name-in-get-request – Sergei B. May 29 '17 at 15:17
  • Note that API Gateway recently added support for [multiple header and query parameters](https://aws.amazon.com/about-aws/whats-new/2018/10/amazon-api-gateway-adds-support-for-multi-parameters/). – dmulter Oct 08 '18 at 15:34
  • The HTTP protocol has always supported multiple query string parameters with the same name. See [RFC 2616|https://tools.ietf.org/html/rfc2616]. It is an often useful feature when building REST APIs. API Gateway is just a low priority product for AWS. – Charlie Reitzel Oct 15 '20 at 03:43
  • Correction: The URL query parameter string is governed by the HTML forms spec, of which there are several. But the _all_ support multiple query parameters, if implicitly. E.g. https://www.w3.org/TR/html52/sec-forms.html#sec-constructing-the-form-data-set – Charlie Reitzel Oct 15 '20 at 14:21
-2

Without providing the API URL in the original post it is hard to verify but something like this is how it would generally be formatted from a form submission.

myurl?postId[0]=1&postId[1]=2
chaduhduh
  • 80
  • 4