2

I have some issues with passing array of parameters to query string for GET method, for example, /resource&item=1&item=2&item=3.

I have tried to pass parameters separated by commas and by &, it doesn`t work. How to configure API Gateway to do this? Can anyone help me?

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
vlad_ter
  • 53
  • 1
  • 4

3 Answers3

2

Your example was using an ampersand (&) instead of a question mark (?) for separating the query string parameter from the path. I'm assuming that's just a typo.

Try passing the array using json syntax like

/resource?item=['1','2','3']

MikeD at AWS
  • 3,565
  • 16
  • 15
0

have you tried this way :

/resource&item[]=1&item[]=2&item[]=3

The way you used would erase the first data by the last data in the url.

Unex
  • 1,747
  • 13
  • 17
  • 1
    The same problem, finally I got the last data – vlad_ter Aug 25 '16 at 14:53
  • 1
    You shouldn't have to configure anything to make this work. This is standard HTTP request format. How are you fetching the datas ? – Unex Aug 25 '16 at 15:04
  • Their Known Issues https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-known-issues.html states that you can't do this: `Duplicated headers are not supported.` – Tom Saleeba May 26 '17 at 00:39
  • `Duplicate query string parameters are not supported.` Which is the OP's question. – CodeMonkeyKing Oct 19 '17 at 20:21
0

What we are doing in our company is to pass data separated by ,. On Backend we explode the parameter and make it array again. I am not sure if there is more better way to do it or not. Let me know if you find any.

like ?items=1,2,3,4

And we get explode items with , through extra code

and get result as [1,2,3,4]

Bhaskar Dabhi
  • 841
  • 1
  • 11
  • 28