Reputation: 4295
When I send a GET request with an empty body to my grails 1.3.7 controller by using the .json file extension (eg http://localhost:8080/myapp/mycontroller/myaction.json) I get a request parsing exception and it seems that grails is trying to parse my empty body to JSON. If I send the same request to the same action but without the .json extension, I don't have any error.
How can I get rid of this error?
Upvotes: 2
Views: 1185
Reputation: 7727
My best stab at this is to have separate clauses in the URL mapping and making sure that for GETtish requests, parseRequest
is set to false
, i.e.
static mappings = {
"/$controller/show/$id?"(parseRequest:false,action:'show'){
constraints {
// apply constraints here
}
}
"/$controller/$action?/$id?"(parseRequest:true){
constraints {
// apply constraints here
}
}
(Yes, this still happens in 2.0.0 RC1)
Upvotes: 1
Reputation: 1289
Do you have an action in your controller that looks like this:
def myaction.json()
if not then you are sending data to an action that doesn't exist. if you are trying to parse JSON then use grails.converters for that matter:
import grails.converters
def jsonData = JSON.parse(params)
also this tuto might help: http://www.ibm.com/developerworks/java/library/j-grails11188/index.html
Upvotes: 0