Creating a RESTful service in CakePHP
Posted
by NathanGaskin
on Stack Overflow
See other posts from Stack Overflow
or by NathanGaskin
Published on 2010-05-10T11:22:26Z
Indexed on
2010/05/14
10:34 UTC
Read the original article
Hit count: 260
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?
© Stack Overflow or respective owner