title: CakePHP API PUT with JSON input
body: <p>I am building an API using CakePHP.</p>
  
  <p>I want to use PUT from my mobile application to update data. The format is JSON as input but $this->data seems to be null.</p>
  
  <p>I call this url (as specified in the docs) from my application:
  /recipes/123.json</p>
  
  <p>And in my "recipes" (or whatever) I have the following controller:</p>
  
  <pre><code>function edit($id = null) {
  
      $this-&gt;User-&gt;id = $id;
      if (empty($this-&gt;data)) {
          $this-&gt;data = $this-&gt;User-&gt;read();
          $message = array('StatusCode' =&gt; 999, 'ERROR' =&gt; "");
      } else {
          if ($this-&gt;User-&gt;save($this-&gt;data)) {
              $message = array('StatusCode' =&gt; 200, 'ErrorCode' =&gt; "");
          } else {
              $message = array('StatusCode' =&gt; 400, 'ErrorCode' =&gt; "UnknownError");
          }
  
      }
  
      $this-&gt;set(compact("message"));
  
      $this-&gt;set('albums', $this-&gt;User-&gt;Album-&gt;find('list'));
  }
  </code></pre>
  
  <p>I correctly receive the JSON response in my application however I get the 999 error - meaning that $this->data is empty.
  In my add function in my controller where it receives JSON using POST - the $this->data gets assigned correctly. And oh ye, if I use POST instead of PUT in my edit - the $this->data gets set, but I cannot save the data..</p>
  
  <p>So.. how do I do this ? :S</p>