#2064 Can not add duplicate query params to Uri

bedla Wed 28 Nov 2012

Hi, I want to construct Uri targeting to PHP Rest server. PHP convention for query params containing arrays is "?usergroupid[]=2&usergroupid[]=3&usergroupid[]=X". I am able parse it from string, return query Map, but I am not able to construct this kind of Uri with plusQuery or plus methods. What am I doing wrong? Or is there any workaround (currently I construct uri as a String and than parse it to Uri using fromStr constructor)? Thx Ivos

addUri := `http://www.google.com/`
addUri = addUri.plusQuery(["a": "1"]); verifyEq(`http://www.google.com/?a=1`, addUri)
addUri = addUri.plusQuery(["a": "1"]); verifyEq(`http://www.google.com/?a=1`, addUri)
addUri = addUri.plusQuery(["a": "2"]); verifyEq(`http://www.google.com/?a=2`, addUri)

brian Wed 28 Nov 2012

Interesting, never seen something like that. But you are right, the query map can't handle duplicate keys since it only stores Str to Str name/value pairs. So I think you will not be able to use the Map based Uri APIs in that case.

bedla Thu 29 Nov 2012

Could you extend Map or create MultiMap ? :-) And support it at Uri API. Thx

Login or Signup to reply.