Poni Poni
Poni Poni

Reputation: 113

How to retrieve body string of request generated by scala-dispatch

I have a request generated by putting map of parameters

  val reqUrl = url("http://example.com")
  val req = reqUrl << Map("key" -> "value")

I need to get request body in order to calculate it's hash. I'm trying this way

  val data = req.toRequest.getStringData

  println(data)

but it results null.

Upvotes: 1

Views: 547

Answers (1)

Andreas Neumann
Andreas Neumann

Reputation: 10884

The request you currently defined is a GET request which normally has no body. So null is the expected body value.

You could try using a POST as described here : http://dispatch.databinder.net/HTTP+methods+and+parameters.html.

val reqUrl = url("http://example.com")
val postReq = reqUrl.POST
val req = postReq << Map("key" -> "value")
req.toRequest.getStringData

Upvotes: 3

Related Questions