Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phil Sturgeon’s REST API always returning: status:0, error:Unknown method

I am always getting the this error.

        {"status":false,"error":"Unknown method."}

But all syntax are correct from my side. because everything is working fine on the browser but same URL integration on the devices gives the 'unknown method error'.

I am using this 'get' method. Sample URL

       SITEURL/api/login/test?req_type=custom

Am I missing something while integrating? Perhaps a setting? I have just included the library and rest config file.

like image 472
Anuja Patil Avatar asked Mar 22 '23 23:03

Anuja Patil


2 Answers

I think your problem is the name of controller is the same with the name of method try to make a test:

if the name of your controller is:

class Test extends REST_Controller{
    //your method name is different from the name of controller class
    public function testget_get(){ 
        echo $this->response(array('test'=> 'test'), 200);
    }
}

I have experienced this problem on hmvc structure.

like image 78
onalbi Avatar answered Apr 25 '23 14:04

onalbi


You also need to check that from device which method your are getting means they are sending 'POST' or 'GET' so you can update your function name accordingly.

In my case I have done the function name as _get to the methods but from device methods of sending parameter is 'POST' which I am trying to access as 'GET'.

So please cross check this once.

like image 29
Anuja Patil Avatar answered Apr 25 '23 13:04

Anuja Patil