Abilash Arjunan
Abilash Arjunan

Reputation: 333

RESTFULL codeigniter api configured and not working

Have included rest.php in config folder,

have added the library files in the library folder.

codeigniter version is ok and 3 or above

php version ok and 5.4 of above

my controller:

require(APPPATH . 'libraries/REST_Controller.php');

class Books_api extends REST_Controller {

  public function book_get()
  {
    // Display all books
    $this->response(array('data'=> 'test'), 200);
  }

  public function book_post()
  {
    // Create a new book
  }
}

my api call:

http://localhost/project_name/index.php/books_api/book
method I tried is GET from postman or httpRequester

my response header

 -- response --
404 Not Found
Date:  Mon, 04 Apr 2016 14:12:56 GMT
Server:  Apache/2.4.7 (Ubuntu)
X-Powered-By:  PHP/5.5.9-1ubuntu4.14
Content-Length:  1130
Keep-Alive:  timeout=5, max=100
Connection:  Keep-Alive
Content-Type:  text/html; charset=UTF-8

Am I doing any mistake here ? may be but I could not figure it out. Please help me out.

Upvotes: 1

Views: 202

Answers (1)

Abilash Arjunan
Abilash Arjunan

Reputation: 333

I see the file name should be Books_api.php and not books_api.php.

May be a silly mistake, but should be useful for rest starters.

Upvotes: 1

Related Questions