Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

When you create a method with the library, you need to append the type of request you are going to make to it.

So, if your method is test, and you are making a GET request to it, it needs to look like this:

function test_get(){
    ...
}

Same with POST requests

function test_post(){
    ...
}

Same with PUT, and DELETE as well.

NB This is only a guess since you didn't include any of your code for some reason.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top