I'm trying to get my REST services up and running, the routing works, but when i do a POST to my service, the RequestHandler->isPost() function returns false.
Could somebody help me out what I'm doing wrong???
Routes.php
Router::connect(
'/authenticate',
array(
'controller' => 'users',
'action' => 'login',
'[method]' => 'POST')
);
Router::parseExtensions('json');
Login function in UsersController.php (for demo purpose i just return if it detects a post or not)
if( $this->RequestHandler->isPost() ) {
$this->set('loginResult', 'post');
$this->set('_serialize', array('loginResult'));
}else{
$this->set('loginResult', 'no post');
$this->set('_serialize', array('loginResult'));
}
Now I use REST Console extension in Chrome to do a call to my REST service (http://path_to_localhost_website/authenticate)
This is the result returned:
Request Headers
- Accept: application/json
- Content-Type: application/json
- Connection: keep-alive
- Origin: chrome-extension: //rest-console-id
- User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_0) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11
Request Body
- Request Url: http://localhost/ris/winsol/winsol_admin/authenticate
- Request Method: POST
- Status Code: 200
- Params: {
- "email": "frederik@the-nerd.be",
- "password": "fd12d90f5670211f5bd4f2816baa7299eb256e1f"
- }
Response Headers
- Status Code: 200
- Date: Thu, 26 Jul 2012 20:25:41 GMT
- X-Powered-By: PHP/5.3.6
- Connection: Keep-Alive
- Content-Length: 25
- Server: Apache
- Content-Type: application/json
- Keep-Alive: timeout=5, max=99
Response Body:
{ "loginResult": "no post" }
I hope somebody can help me out, because it is driving me mad :-)
-- 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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
No comments:
Post a Comment