I want to pass list of enum values as HTTP query parameter. The entry point of the server side looks like this:
@GET
@Path("/getMyResult")
public MyResultType getMyResult(@QueryParam("me") final List<MyEnum> myEnums)
This cannot be modified. Consider MyEnum
contains values MyValue1
, MyValue2
, MyValue3
and MyValue4
. (MyResultType
is not relevant for this question.) Passing only one value, as follows, works fine (which is a bit strange for me):
http://localhost/getMyResult?me=MyValue1
However, passing list of elements this way:
http://localhost/getMyResult?me=[MyValue1,MyValue3,MyValue4]
or this way:
http://localhost/getMyResult?me=MyValue1,MyValue3,MyValue4
or this way:
http://localhost/getMyResult?me=["MyValue1","MyValue3","MyValue4"]
does not work, it throws exception something like this (error message to the first option):
RESTEASY001720: Unable to extract parameter from http request: javax.ws.rs.QueryParam(\"me\") [...]
No enum constant com.mycompany.myapp.MyEnum.[MyValue1,MyValue3,MyValue4]
Can anyone tell me how to pass a list of MyEnum
elements as HTTP GET query parameter? Thank you!
For this (and other cases you need to pass a List
) you must insert name of the parameter for each element.
In this way:
http://localhost/getMyResult?me=MyValue1&me=MyValue3&me=MyValue4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With