Reputation: 279
I am developing restful services with PHP Cake. I have developed all get services. But I am stucked in post services.
Problem is that, I am unable to get post data. I am getting noting in $this->data
Here is code of one controller function.
function signin() {
$this->view = 'Webservice.Webservice';
$message = "Request Received";
if (!empty($this->data)) {
$message = "Request has data";
}
$this->set(compact('message'));
}
Here is my request data
POST http://localhost/blog/posts/signin HTTP/1.1
User-Agent: Fiddler
Host: localhost
Content-Length: 25
username=abc&password=abc
Please help me out here.
Thanks,
Upvotes: 0
Views: 309
Reputation: 7882
Cake only populates the request data array by data sent to PHP that is prefixed with 'data'.
POST your username and password like this, instead:
data[username]=abc&data[password]=abc
This will tell Cake to place it in $this->request->data
.
Upvotes: 1