Always getting "status":false while using rest api in codeigniter 2.0

102 views Asked by At

I am using Ashimante Rest Server API in my project.

This is what I did:-

  1. I have put the Rest.php controller in the application/libraries folder
  2. I have created webservice-v1 folder inside the application/controllers/ folder i.e. application/controllers/webservice-v1
  3. I have Controller files rest_api_common.php and webservice_test.php inside the webservice-v1 folder.

This is my rest_api_common.php code:-

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require(APPPATH . 'libraries/Rest.php');
class Rest_api_common extends REST {

    // some variable declarations //

    public function __construct() {
        parent::__construct();
        // loading models and custom config files// 
    }
}

I want the variables and functions available to all the webservice functions. So my webservice_test.php file code goes like this:-

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
include('rest_api_common.php');
class Webservice_test extends Rest_api_common
{
    function  __construct(){
        parent::__construct();
    }

    public function mongodata_post()
    {
        $this->response(array(),200);
    }
}

I have defined route like this:-

$route['rest-api/v1/mongodata'] = "webservice-v1/webservice_test/mongodata_post";

Using postman app, I am calling the API like this using POST method:-

http://testdomain.com/rest-api/v1/mongodata

I am getting this response:-

{"status":false,"error":false}

What am I doing wrong?

0

There are 0 answers