Creating a RESTful service in CakePHP
- by NathanGaskin
I'm attempting to create a RESTful service in CakePHP but I've hit a bit of a brick wall.
I've enabled the default RESTful routing using Router::mapResources('users') and Router::parseExtensions(). This works well if I make a GET request, and returns some nicely formatted XML. So far so good.
The problem is if I want to make a POST or PUT request. CakePHP doesn't seem to be able to read the data from the request. At the moment my add(), edit() and delete() actions don't contain any logic, they're simply setting $this-data to the view.
I'm testing with the following cURL command:
curl -v -d "<user><username>blahblah</username><password>blahblah</password>" http://localhost/users.xml --header 'content-type: text/xml'
Which only returns a 404 header. If I remove the --header parameter then it returns the view but no data is set.
It feels like I'm missing something obvious here. Any ideas?