kvz / cakephp-rest-plugin

Discontinued: recent cakephp versions overlap functionality, there also is @ceeram's plugin. Painless REST server Plugin for CakePHP
http://kvz.io/blog/2010/01/13/cakephp-rest-plugin-presentation/
169 stars 37 forks source link

Empty data when using plugin on CakePHP 2.1.2 #24

Closed iamdriz closed 11 years ago

iamdriz commented 11 years ago

I have setup this plugin as described in the documentation:

// UsersController
public $components = array (
        'Rest.Rest' => array(
            'catchredir' => true,
            'actions' => array(
                'extract' => array(
                    'test' => array('users'),
                ),
            ),
            'ratelimit' => array(
                'enable' => false
            )
        ),
    );

public function test(){
        $users = array(
            array('name' => 'user-1'),
            array('name' => 'user-2'),
            array('name' => 'user-3')
        );
        $this->set(compact('users'));
    }

// routes
Router::mapResources(array('users'));

Router::parseExtensions('rss','json','xml');

but the returned JSON has empty data...

{
    "data": {
        "User": []
    },
    "meta": {
        "status": "ok",
        "feedback": [],
        "request": {
            "http_host": "sample.com",
            "http_user_agent": "Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit\/537.22 (KHTML, like Gecko) Chrome\/25.0.1364.29 Safari\/537.22",
            "server_addr": "##.##.###.###",
            "remote_addr": "##.###.###.###",
            "server_protocol": "HTTP\/1.1",
            "request_method": "GET",
            "request_uri": "\/users\/test.json",
            "request_time": 1357946870
        },
        "credentials": {
            "class": null,
            "apikey": null,
            "username": null
        },
        "time_epoch": "1357946871",
        "time_local": "Fri, 11 Jan 2013 15:27:51 -0800",
        "version": "0.3"
    }
}

Does this plugin work with v2.1.2? Any ideas on why the data is empty?

tuto1902 commented 11 years ago

I have the same problem, except that I´m using CakePHP 2.3.0