views:

40

answers:

1

I have built a simple Grails app, with a domain-class and its controller (with the default scaffold functionality).

I want to use this for an Android app.

I had to get my objects in the JSON format, and thanks to stackoverflow it's been easy ;)

Now I have to put data. I should make a POST call to http://localhost:8080/MyApp/person/save with parameters, I suppose. But I can't succeed using RESTClient or other simple utilities/firefox addons that GET/POST data over an HTTP server.

The response web page is an error web page, saying "Property 'name' can't be null" or similar... as if I have no parameters passed. Perhaps I'm not able to make a POST request on a page?! o_O

And how can I enable GET, in Grails, to insert objects?

Thank you.

+1  A: 

Funny, I think I am about 2 weeks ahead of you on a similar project. :)

When you do your Post, be sure and include the ?format=json on the end of your URL and grails will automagically parse the params with no extra code in the controller. Isn't grails wonderful?

Lloyd Meinholz
It's funny, you're right ;)However, although your answer is not about my question, I have to say that this "automagic" you're talking about is not happening in my app.I had to rewrite some parts of the controller to get the JSON output... Are you sure you didn't touch anything to get that? :)
daliz
My controller doesn't do anything special. I will double check how the client is sending the json and see if I can get you more info.
Lloyd Meinholz