No parser for ratpack.form.internal.DefaultF[email protected] and content type application/json

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

No parser for ratpack.form.internal.DefaultF[email protected] and content type application/json

Borre
Hi!

I'm trying to create an application using Backbone and Ratpack, and when im using the default Backbone  models "save" method, I run into this error:

No parser for ratpack.form.internal.DefaultFormParse @ 7ccc4301 and content type application / json

The code that I'am using in my ratpack.groovy is:

import static ratpack.form.Forms.form
import static ratpack.groovy.Groovy.ratpack
import static groovy.json.JsonOutput.toJson
import static ratpack.groovy.Groovy.groovyTemplate

ratpack {
    handlers {
        get {
            render groovyTemplate("index.html")
        }

        prefix("admin") {
            get {
                render groovyTemplate("admin.html")
            }

            post("post") {
                def form = parse form()
                response.send "application/json", toJson("{result: true}")
            }
        }

        assets "public"
    }
}


There is no support for post with json type? Or am I making a mess?

My ratpack version is classpath "io.ratpack:ratpack-gradle:0.9.0" from lazybones.

Many thanks!

Reply | Threaded
Open this post in threaded view
|

Re: No parser for ratpack.form.internal.DefaultF[email protected]4301 and content type application/json

Luke Daley
Administrator
It's saying that the request contains JSON but you are trying to parse it as a form.

You can see some examples of parsing JSON here: https://github.com/ratpack/ratpack/blob/master/ratpack-jackson/src/test/groovy/ratpack/jackson/JacksonParsingSpec.groovy