Yii Framework Forum: How To Apply Restfull Service To Controllers Inside Modules. - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How To Apply Restfull Service To Controllers Inside Modules. Rate Topic: -----

#1 User is offline   ashokkarthick 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 17-July 12

Posted 23 February 2014 - 05:22 AM

I have a controller named Notes in modules admin.

i.e, The path is app/protected/modules/admin/controllers/NotesController

I want to apply restfull service to this controller.

I had installed the extensions named RESTFullYii ,
the link is http://www.yiiframew...ion/restfullyii , and i had followed the instructions to install this extensions,

I had create a sample test controller in protected/controller folder ,and when i tried it with below functions inside controller,

  public function restEvents() {
         $this->onRest('model.instance', function() {
             return new ProfileNotes();
            });
    }


it throws output as {"success":false,"message":"Unauthorized","data":{"errorCode":401,"message":"Unauthorized"}}

if i tried it with
 public function restEvents() {
          $this->onRest('req.auth.ajax.user', function() {
                    return true;
                });
    }

it's working and outputs the json data.
the url for that is localhost/example/api/Sample


But the problem is when i tried to apply the same feature to controllers inside module
it throwing the error,

CHttpException

The system is unable to find the requested action "error"


the url is localhost/example/admin/api/Notes

iam doing anything wrong ,
Anyone had successfully implemented the restfull service inside modules.
0

#2 User is offline   Fire 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 55
  • Joined: 07-August 10

Posted 29 March 2014 - 01:24 AM

Hi,
I also experienced this error when using RestfullYii, but in my case, it had to do with another extension yii-user.

It seamed that Yii-user had a few incompatible functions I guess that webUser didnt like.
I managed to edit ProfileFieldController.php
and modified line 493 public function loadModel() to
public function loadModel($id = NULL, $model = false)

and line 549 protected function performAjaxValidation($model)
to: protected function performAjaxValidation($model, $form)
and this seamed to fix the problem.

I hope this helps

View Postashokkarthick, on 23 February 2014 - 05:22 AM, said:

I have a controller named Notes in modules admin.

i.e, The path is app/protected/modules/admin/controllers/NotesController

I want to apply restfull service to this controller.

I had installed the extensions named RESTFullYii ,
the link is http://www.yiiframew...ion/restfullyii , and i had followed the instructions to install this extensions,

I had create a sample test controller in protected/controller folder ,and when i tried it with below functions inside controller,

  public function restEvents() {
     	$this->onRest('model.instance', function() {
         	return new ProfileNotes();
            });
    }


it throws output as {"success":false,"message":"Unauthorized","data":{"errorCode":401,"message":"Unauthorized"}}

if i tried it with
 public function restEvents() {
          $this->onRest('req.auth.ajax.user', function() {
                    return true;
                });
    }

it's working and outputs the json data.
the url for that is localhost/example/api/Sample


But the problem is when i tried to apply the same feature to controllers inside module
it throwing the error,

CHttpException

The system is unable to find the requested action "error"


the url is localhost/example/admin/api/Notes

iam doing anything wrong ,
Anyone had successfully implemented the restfull service inside modules.

http://b3dmultitech.com - Delivering Education and Business through 3D Gaming Media
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users