I have a problem with the play framework 2.1.1 (Java) telling me that I am sending Invalid JSON. There has been a similar /possibly the same issue for the play framework 2.x and 2.1.0, but it was supposed to be resolved in play framework 2.1.1 afaik: See Invalid JSON in Play Framework 2.1
This is what I am doing in the code, I have tried making it a bit shorter:
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;
import play.libs.Json;
import play.mvc.BodyParser;
@BodyParser.Of(BodyParser.Json.class)
public static Result login() {
JsonNode json = request().body().asJson();
}
When I run:
curl -v -H "Content-Type: application/json" -X POST -d '{"email":"[email protected]","password":"test"}' http://localhost:9000/mobile/login
I get the following response:
< HTTP/1.1 400 Bad Request
< Content-Type: text/html; charset=utf-8
< Content-Length: 1917
...
<p id="detail">
For request 'POST /mobile/login' [Invalid Json]
</p>
...
I have cleaned my project and rerun it several times. When running play about I get the following output:
[info] Loading project definition from /path/to/project
[info] Set current project to FFPushAlarmPlay (in build file:/path/to)
[info] This is sbt 0.12.2
[info] The current project is {file:/path/to}...
[info] The current project is built against Scala 2.10.0
[info] Available Plugins: play.Project, sbt.PlayProject, com.typesafe.sbteclipse.plugin.EclipsePlugin, com.typesafe.sbtidea.SbtIdeaPlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.9.2
Am I doing something awfully wrong? Any help would be greatly appreciated as this is my first Play 2 project!
Update: I forgot to mention that I also have an iOS client which automagically builds the JSON using AFNetworking and I also get a Invalid JSON response there. So it doesn't seem to be invalid JSON causing this...