[2.5-scala] WS API is unintuitive

20 views
Skip to first unread message

Marius Soutier

unread,
Sep 30, 2016, 7:04:33 AM9/30/16
to play-fr...@googlegroups.com
Since my issue (https://github.com/playframework/playframework/issues/6611) was closed, I'm reposting the message here as suggested:

The WS API makes a strange distinction between calling withMethod(<method>) and calling <method>() directly. Most notably, I can only call the withBody method after calling withMethod.

Example:

ws
  .url("http://example.org/endpoint";)
  .withMethod("POST")
  .withBody(StreamedBody(source))
  .execute()
ws
  .url("http://example.org/endpoint";)
  .post(File)

It took me a while to realize that the second version executes directly. However what I don't understand is that the second version cannot stream its body.

I suggest that either post()put() and so on get renamed to executePost(), or that they support WSBody as well.

Reply all
Reply to author
Forward
0 new messages