Cakephp 3 has bug with Rest API!
Methods as get, post, delete work ok and receive data in $this->request->data!
But method put and patch don’t work, because request receive empty data!
All data receive in in params as varible “?” ($this->request->params[’?’)]
And I must to write
public function edit($id) {
$data = !empty( $this->request->getData() ) ? $this->request->getData() : $this->request->params['?'];
$payment = $this->Payments->get($id);
if ($this->request->is(['patch', 'post', 'put'])) {
$payment = $this->Payments->patchEntity($payment, $data);
if ($this->Payments->save($payment)) {
$message = 'Saved';
} else {
$message = 'Error';
}
}
$this->set([
'message' => $message,
'_serialize' => ['message']
]);
}
Do anyone how fix this bug?
P.S.
And remember Putin - Huylo!