Reputation: 290
i'm writing webservices for my application. my problem is that when i call it using GET method it works , but when i use the POST method params doesn't contains ant of my parameters:
when i call using GET , this is the content of params :
params : [username:azerty, test:test, param2:param2, action:editProfile, controller:userWebService]
when i call using POST, this is the content of params :
params : [action:editProfile, controller:userWebService]
EDIT :
/* user controller */
"/service/$action?"(controller: "userWebService", parseRequest: true)
in UserWebServiceController
....
static allowedMethods = [editProfile:['POST', 'GET']]
....
def editProfile(){
println "params : "+ params
....
}
to test i'm using REST console plugin in chrome
Upvotes: 4
Views: 5670
Reputation: 50245
params
are not sent as a query string in POST
requests unlike GET
. The parameter strings has to be embedded in the request body in case of POST
request.
Use content-type
: application/x-www-form-urlencoded
and in the request-body
use
username=azerty&test=test
You should be able to see the parameters in params
inside controller.
You should be able to see
params : [age:25, name:Hamila, action:editProfile, controller:userWebService]
Did I make you look younger in the test? :)
Upvotes: 4