Search code examples
grailsgrails-controller

Grails Send Version as part of a PUT request


Using Grails 2.3.9

I'm trying to send the version number as part of a PUT request. In the controller side I do actually receive it (request.JSON) but when populating that data with instance.properties = params it is missing.

Is there a flag I have to set in Config.groovy to have the "version" populated too, similar to grails.converters.domain.include.version = true for having the "version" in the request?

If not, is this achievable in another way?

Update: this should be independent of the sent data (JSON or XML)


Solution

  • Normally you do not want the version field to be populated during data binding but if that really is what you want, you can configure it to be bindable...

    class SomeDomainClass {
    
        // ... 
    
        static constraints = {
            version bindable: true
        }
    }
    

    Make sure that is really the behavior you want before doing that though.