0

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:

enter image description here

What am I doing wrong?

halfer
  • 19,824
  • 17
  • 99
  • 186
kofhearts
  • 3,607
  • 8
  • 46
  • 79

1 Answers1

0

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

kofhearts
  • 3,607
  • 8
  • 46
  • 79
  • 3
    It seems as a problem with Windows terminal running curl query, not a Grails issue. Please check similar thread: https://stackoverflow.com/questions/11834238/curl-post-command-line-on-windows-restful-service – Michal_Szulc Mar 20 '23 at 15:34