Wednesday, 18 September 2013

Missing parameters with RESTful request when upgrading to Grails 2.3.0

Missing parameters with RESTful request when upgrading to Grails 2.3.0

I am using Grails with RESTful to develop my web application. Everything
works fine, till I upgrade my application to Grails 2.3. Here is my
UrlMappings: I still send request, submit or do some other things
normally, but in POST, PUT requests, the parameters are missing. Server
just recognize only the parameters I put on the URL directly, but the
remain I enclose in form or model when submit cannot be found in the
"params" variable. He is my UrlMappings:
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{ constraints {} }
name apiSingle: "/api/$controller/$id"(parseRequest:true){
action = [GET: "show", PUT: "update", DELETE: "delete"]
constraints { id(matches:/\d+/) }
}
name apiCollection: "/api/$controller"(parseRequest:true){
action = [GET: "list", POST: "save"]
}
name api2: "/api/$controller/$action"(parseRequest:true)
name api3: "/api/$controller/$action/$id"(parseRequest:true)
"/"(view:"/welcome")
"500"(view:'/error')
}
}
I have read the latest document of Grails 2.3, at
http://grails.org/doc/latest/guide/theWebLayer.html#restfulMappings
but I think it is not clear. I have tried it follow the documentation but
have no result. And there are no any sample about using Grails 2.3 with
RESTful for me to refer.
How can I make it work normally as before, and can access all parameter
values in REST request? Thank you so much!

1 comment:

  1. I am also facing the same issue, Did you find any solution?
    Please let me know, If you have found a solution for this.

    ReplyDelete