Hi, I am developing an API using CakePHP 2.1.1. I have configured the following route:
Router::connect("/api/accounts/:id", array('controller' => 'accounts', 'action' => 'edit', 'api' => true, '[method]' => array('PUT', 'POST')), array('pass' => array('id'), 'id' => '\d+')); Then I have the following action: public function api_edit($id = null) { if ($this->request->is('put') || $this->request->is('post')) { if ($this->Account->save($this->request->data)) { ... } else { throw new InternalErrorException(); } } else { throw new MethodNotAllowedException(); } } I am testing the API using curl. When using POST the action saves the data and everything goes as expected: $ curl -i -X POST -d "data[Account][id]=1&data[Account][name]=FooBar" http://example.com/api/accounts/1.json HTTP/1.1 200 OK However, when using PUT $this->request->data is not populated with the submitted data but returns an empty array(): $ curl -i -X PUT -d "data[Account][id]=1&data[Account][name]=FooBar" http://example.com/api/accounts/1.json HTTP/1.1 500 Internal Server Error Both requests are entering the action and passing the check of $this->request->is(...). But printing the content of $this->request->databefore saving just reveals this scenario. Any ideas? If not I'll submit this issue as a ticket. Thanks!! -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php