How do I set params for WS.post() in play 2.1 Java

后端 未结 7 1752
慢半拍i
慢半拍i 2020-12-09 20:43

I\'m trying to perform a post with play.api.libs.ws.WS but I can\'t figure out how to set the params, my code:

Promise promise = WS.url(Play.         


        
7条回答
  •  不知归路
    2020-12-09 21:36

    Try constructing the request like this:

    WS.url("http://localhost:9001")
        .setQueryParameter("param1", "foo")
        .setQueryParameter("param2", "bar")
        .post("content");
    

    The method url(java.lang.String url) returns a WS.WSRequestHolder reference which can be used to modify the original request using chained calls to setQueryParameter.

提交回复
热议问题