Ho cercato di fare una richiesta POST nel mio controller CodeIgniter RestClient per inserire dati nel mio RestServer, ma sembra che la mia richiesta POST sia sbagliata.Come inviare una richiesta di posta all'API RESTserver in php-Codeigniter?
Ecco la mia richiesta RestClient POST 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);
Questo è un controllore di mio RestServer: paziente
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'));
}
}
Questo è user_model
public function insertVisit($insertdata)
{
$this->db->insert('visit',$insertdata);
}
prega di formulare domande. Cosa non funziona, qual è l'errore ecc ... – Kyslik
@Kyslik Ho cercato di fare una richiesta POST nel mio controller CodeIgniter RestClient per inserire dati nel mio RestServer CodeIgniter, ma non inserisce mai dati nel mio database. – Madhu
Ricevi il valore da $ this-> response'? Se è così, potresti pubblicare il post. '$ this-> response (array ($ _ POST))' – Linesofcode