title: Getting Grails to read my submitted JSON PUT AJAX request?
body: <p>I have my form here, nothing out of the ordinary as a Grails app is concerned.</p>
  
  <pre><code>&lt;g:form url="[resource:myClass, action:'update']" method="PUT" &gt;
      &lt;fieldset class="form"&gt;
          &lt;g:render template="form"/&gt;
      &lt;/fieldset&gt;
      &lt;fieldset class="buttons"&gt;
          &lt;g:actionSubmit action="update" value="update" /&gt;
      &lt;/fieldset&gt;
  &lt;/g:form&gt;
  </code></pre>
  
  <p>If I do a regular submit, everything works fine.  But if I try to use my restfulcontroller, I get a successful save message, but it never saves anything.</p>
  
  <pre><code>import grails.rest.RestfulController
  import grails.transaction.Transactional
  
  class MyClassRestController extends RestfulController&lt;MyClass&gt; {
      static allowedMethods = [update: "PUT"]
      @SuppressWarnings("GroovyUnusedDeclaration")
      static responseFormats = ['json', 'xml']  
  
      @Transactional
      def update(MyClass myClassInstance) {
          myClassInstance.save flush:true, failOnError: true
          respond new Expando(success: true, message: 'updated', myClass: myClassInstance)
      }
  }
  </code></pre>
  
  <p>This seems straightforward, and here is how I am submitting it: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      $(function () {
          var frm = $('form');
          frm.on('submit', function (e) {
              e.preventDefault();
              $.ajax({
                  type: "PUT",
                  url: putUrl,
                  data: JSON.stringify(frm.serializeArray()),
                  contentType: "application/json; charset=utf-8",
                  dataType: "json",
                  success: function (data) {
                      console.info(data);
                  },
                  failure: function (errMsg) {
                      console.info(errMsg)
                  }
              });
          });
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>Everything appears to PUT correct in the console, I get my success message back and the MyClassInstance, but it is the unedited MyClass - it is as if it is looking it up via GORM and ignoring what my PUT is sending.  What am I forgetting?  Do I have to set anything for the PUT to 'take hold' and the myClassInstance?</p>
  
  <p>Here is my request: <img src="https://i.stack.imgur.com/eqwkB.png" alt="enter image description here"></p>
  
  <p>Ignore the created date part, it is overwritten.  And here is the response:</p>
  
  <pre><code>{   
      "metaPropertyValues": [     
          {
              "class":"groovy.lang.MetaExpandoProperty",
              "modifiers":1,
              "name":"success",
              "type":"java.lang.Object"
          },  
          {
              "class":"groovy.lang.MetaExpandoProperty",
              "modifiers":1,
              "name":"message",
              "type":"java.lang.Object"
          },
          {
              "class":"groovy.lang.MetaExpandoProperty",
              "modifiers":1,
              "name":"auctionUser",
              "type":"java.lang.Object"
          }
      ],
      "properties":{
          "success":true,
          "message":"AuctionUser updated",
          "auctionUser":{
              "class":"Auction.AuctionUser",
              "id":2,
              "addressCity":"Minneapolis",
              "addressState":"MN",
              "addressStreet":"1234 ABC Street",
              "addressZip":"55408",
              "created":"2015-03-31T05:00:00Z",
              "firstName":"Trat",
              "lastName":"Tauer",
              "username":"trat@naspinski.net"
          }
      }
  }
  </code></pre>
  
  <p>You can ignore most of it, but notice that the addressStreet and firstName are returned as the previous values and not as the JSON that was passed via the PUT.  What is wrong here?</p>