Cakephp 4.1.1
To render the response as Json:
$this->set(['response' => $api_response]);
$this->viewBuilder()->setOption('serialize', true);
$this->RequestHandler->renderAs($this, 'json');
this works fine !
To render the response as Xml i tried:
$this->set(['response' => $api_response]);
$this->viewBuilder()->setOption('serialize', true);
$this->RequestHandler->renderAs($this, 'xml');
this results in error = "Serialization of View data failed".
Why does xml results in error while json does not? (I did not create any View files)