2

I'm using backbone and CodeIgniter Rest Server, The post and get requests from backbone works fine But the put and delete requester gets 404 error with the response of {"status":false,"error":"Unknown method."}

edit: I changed the source code to see which method codeigniter is trying to run my controller url is

http://local/host/impacto/index.php/interviews/

the put request url is

http://localhost/impacto/index.php/interviews/13

and the function that codeigniter is running is 13_put instead of input_put

My controller

class Interview extends REST_Controller {

function __construct(){

    parent:: __construct();
}

public function index_get(){

    echo "get";
}

public function index_post(){

    echo "post";
}

public function index_put($id){

    echo "update: " . $id;
}

public function index_delete($id){

    echo "delete: " . $id;
}
}
3

1 Answer 1

3

I had the same problem. Accordingly, it's not an error - https://github.com/philsturgeon/codeigniter-restserver/issues/255 - you have to either overtly specify "index" as the function ("Interview/index/{id}"), or alternatively give your method a name ("rest_put($id)", so accessed Interview/rest/{id}")

Sign up to request clarification or add additional context in comments.

1 Comment

This is important as the controller has to know which method to call - it's receiving the parameter where it expects the method name. You could always try to use _remap and route to the method you expect based on custom logic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.