I'm working with codeigniter REST API. In my API call i'm trying to get value from $this->input->get('id') but does not get any value from the get.
public function data_get($id_param = NULL){
$id = $this->input->get('id');
if($id===NULL){
$id = $id_param;
}
if ($id === NULL)
{
$data = $this->Make_model->read($id);
if ($data)
{
$this->response($data, REST_Controller::HTTP_OK);
}
else
{
$this->response([
'status' => FALSE,
'error' => 'No record found'
], REST_Controller::HTTP_NOT_FOUND);
}
}
$data = $this->Make_model->read($id);
if ($data)
{
$this->set_response($data, REST_Controller::HTTP_OK);
}
else
{
$this->set_response([
'status' => FALSE,
'error' => 'Record could not be found'
], REST_Controller::HTTP_NOT_FOUND);
}
}
In the above code $id doesn't return any value.
Hope this will help you :
Use either
$this->input->get('id')or$this->get('id')both should workYour
data_getmethod should be like this :