grails 3 rest-api profile GET

567 views Asked by At

I am using grails 3 rest-api profile. I created generated simple domain class

@Resource(readOnly = false, formats = ['json', 'xml'])
class User {
    String name
    String address
    Date dateOfBirth
}

while http://localhost:8080/user/ will give me back json list of users, if I try http://localhost:8080/user/1 if gives back :

{"message":"Not Found","error":404}

what gives ?

2

There are 2 answers

0
rdmueller On

seems to be a bug. If you specify a uri it works:

@Resource(uri='/user/', readOnly = false, formats = ['json', 'xml'])
class User {
    String name
    String address
    Date dateOfBirth
}
0
1977 On

actually I since found out that the url exposed is /user/show/1

since RestResource automatically exposes a controller based on grails.rest.RestfulController you can look in that class for the full list of methods