Getting JSON body for a HTTP PUT or POST

I’m trying to write a Groovy app with an API. The API should be able to response to PUT HTTP requests with a JSON body, e.g something like this

mappings {
path("/:type/:id") {
action: [
GET: “_api_show”,
PUT: “_api_put”
]
}
}

It works in that I get _api_put called, but there doesn’t seem to be a place to actually get the JSON payload that is being sent.

Can someone help me out?

The recipe It’s buried down in the REST endpoint tutorial:

As an alternative to passing the variables in the URL path, we could have sent a json string and used it in this manner.
def command = request.JSON?.command

Thank you! that was exactly what I’m looking for.