Play-ws post() "adaption of argument list deprecation" compile error

scala

(Julian Wilson) #1

Hi,

I’m trying to use play-ws to make some HTTP requests on the server-side and I’m using the .post() method on the ws object. I’m getting the compiler error where it is trying to coerce Unit into the arguments of .post(). My play version is 2.6.7 and my scala version is 2.12.4. Here’s the code (pretty simple)

z.post().map{
          response => logger.info(response.toString)
        }

and my error:

[error] /home/julian/IdeaProjects/my-app/app-admin/src/main/scala/admin/controllers/HomeController.scala:94:15: Adaptation of argument list by inserting () is deprecated: this is unlikely to be what you want.
[error]         signature: WSRequest.post[T](body: T)(implicit evidence$2: play.api.libs.ws.BodyWritable[T]): scala.concurrent.Future[WSRequest.this.Response]
[error]   given arguments: <none>
[error]  after adaptation: WSRequest.post((): Unit)
[error]         z.post().map{
[error]               ^
[error] one error found
[error] (app-admin/compile:compileIncremental) Compilation failed
[error] Total time: 4 s, completed 5-Apr-2018 6:08:38 PM

Any ideas? I’m guessing it some version issue?

Thanks


(Rich Dougherty) #2

Scala is expecting you to call z.post(body). Since you’re just saying z.post() it’s assuming you’re supplying () as the body, i.e. doing the same as z.post(()). What body do you want to post?


(Julian Wilson) #3

Thank you! Silly mistake. The endpoint was requiring get() and so this wasn’t necessary.


(Rich Dougherty) #4

No problem, glad it’s working for you.