1

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.

9
  • 3
    File name is ucfirst i.e. Books_api.php? Commented Apr 4, 2016 at 14:39
  • If you visit the URL in your web browser then it fails as well? Commented Apr 4, 2016 at 15:02
  • @Tpojka - no its books_api.php Commented Apr 4, 2016 at 15:44
  • @MonkeyZeus - yes. Commented Apr 4, 2016 at 15:44
  • 1
    I downloaded the lang file and all fixed, get working now. Thanks for your time and comments. was useful. Commented Apr 4, 2016 at 16:09

1 Answer 1

1

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.

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

Comments

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.