Reputation: 1202
I am using Play 2.5 and I need advices on a compile error. It is saying that I have given JsNode value but JsValue expected. I don't know what is wrong.
val response : Future[Result] =
controller.foo()
.apply(FakeRequest(POST, "/form")
.withHeaders(CONTENT_TYPE -> JSON)
.withJsonBody(Json.parse("""{"name":"Jacek","age":41}""")))
Upvotes: 3
Views: 171
Reputation: 14803
I just checked your code:
lazy val controller = inject[HomeController]
controller.index()
.apply(
FakeRequest("POST", "/form")
.withJsonBody(Json.parse("""{"name":"Jacek","age":41}""")))
This works.
So my guess is: You have imported the wrong Json
object.
Make sure you imported: play.api.libs.json.Json
Upvotes: 1