My web service request handler is as follows
@POST
@Path("/requestPath")
public String addChallengersToLeague(
@FormParam("name") String name,
@FormParam("values") List values);
since WSRequestHolder accepts a Map in setQueryParameter method, I am not able to send parameter list with same name.
I can send request from POSTMAN with multiple parameters having name 'values'and it works fine.
Can you suggest how to do the same using play? I am using play 2.1.3
Thanks in advance.
解决方案
This can be done using play.libs.WS.WSRequest API
Following is a simple example
WSRequest request = new WSRequest(""); //Method can be GET, POST etc
request.setUrl("");
request.setHeader("Content-Type", "application/x-www-form-urlencoded");
com.ning.http.client.FluentStringsMap map = new com.ning.http.client.FluentStringsMap();
map.add("name", "aniket");
Set values= new HashSet();
values.add("1");
values.add("2");
values.add("3");
values.add("4");
map.add("values", values);
request.setQueryParameters(map);
Promise response = request.execute();
You can then use response.get().getBody() to get response body.