I've been trying to make a POST request in my CodeIgniter RestClient controller to insert data in my RestServer, but seems like my POST request is wrong.
Here is my RestClient POST request in controller:
$method = 'post';
$params = array('patient_id' => '1',
'department_name' => 'a',
'patient_type' => 'b');
$uri = 'patient/visit';
$this->rest->format('application/json');
$result = $this->rest->{$method}($uri, $params);
This is my RestServer's controller: patient
function visit_post()
{
$insertdata=array('patient_id' => $this->post('patient_id'),
'department_name' => $this->post('department_name'),
'patient_type' => $this->post('patient_type') );
$result = $this->user_model->insertVisit($insertdata);
if($result === FALSE)
{
$this->response(array('status' => 'failed'));
}
else
{
$this->response(array('status' => 'success'));
}
}
This is user_model
public function insertVisit($insertdata)
{
$this->db->insert('visit',$insertdata);
}