Grails as a pure REST backend good? Having technical difficulties to follow the documentation.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Grails as a pure REST backend good? Having technical difficulties to follow the documentation.

martin.wolff
Dear all,

(1) I had been working with Grails many years back. Looking for a good backend framework now (frontend will use angular.js). My first question is whether Grails is still a good choice to provide pure REST services?

(2) I tried to follow the documentation (section 9.1.5.1). I have created a domain class called "Restaurant" having two attributes (title, website). Then I have created a RestaurantController having following code:

import grails.rest.RestfulController
import grails.transaction.*

@Transactional(readOnly = false)
class RestaurantController extends RestfulController  {

 
static responseFormats = ['xml', 'json']

 
RestaurantController() {
   
super(Restaurant)
 
}

}

I have sent a POST request to the URI "http://localhost:8080/restaurant" with following content "title=Asia+Imbiss&website=www.asia-imbiss.com". But no matter which URL I use I get a java.lang.NullPointerException exception caused by Cannot invoke method count() on null object (see screenshot). What am I doing wrong here?

Btw: If I don't create a controller and use the @Resource(uri='/restaurant')like stated in 9.1.1, it works fine!








--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/3541acc4-54c0-4cfd-ab08-3d3ebc28ffed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails as a pure REST backend good? Having technical difficulties to follow the documentation.

martin.wolff
I think i found the issue. It is workign, however, not with the URIs provided in the documentation:



If I want to save a new entry, I need to request the URI "/restaurant/save" and if I want to view an existing data set I need to request e.g. "/restaurant/show/1"

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/d6b106b2-31f4-4629-b76c-46b272bf2314%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Grails as a pure REST backend good? Having technical difficulties to follow the documentation.

Jeff Brown

> On Jan 22, 2016, at 5:16 AM, [hidden email] wrote:
>
> I think i found the issue. It is workign, however, not with the URIs provided in the documentation:
>
>
>
>
>
> If I want to save a new entry, I need to request the URI "/restaurant/save" and if I want to view an existing data set I need to request e.g. "/restaurant/show/1”
>

I expect you have a problem with your url mappings.  You probably want something like this…

    “/restaurants"(resources: ‘restaurant’)

See https://github.com/jeffbrown/restaurants.



JSB

Jeff Scott Brown
Principal Software Engineer
Grails Development Team
Object Computing Inc.
http://www.ociweb.com/

Autism Strikes 1 in 166
Find The Cause ~ Find The Cure
http://www.autismspeaks.org/

--
You received this message because you are subscribed to the Google Groups "Grails Dev Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/grails-dev-discuss/FE252A99-D1DF-4AA2-B5C1-33F7F88FABF8%40ociweb.com.
For more options, visit https://groups.google.com/d/optout.