I created a new Grails 4.0.10 app using rest application profile. I would like to check how the Resource annotation works. According to the docs, if I annotate Resource on domain then I don't need to write a controller.
The domain I have is:
package book
import grails.rest.Resource
@Resource(uri='/books', formats=['json', 'xml'])
class Book {
String title
static constraints = {
}
}
I run the app. When I run this curl
command to create a book:
`curl -i -X POST -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}'` localhost:8080/books
I get the following error:
What am I doing wrong?
This is strange
but i tried in windows cmd prompt
curl -i -X POST -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}' localhost:8080/books
it thows error
but when i tried in Git Bash
curl -i -X POST -H "Content-Type: application/json" -d '{"title":"Along Came A Spider"}' localhost:8080/books
it succeeds