When setting the contect_type parameter for each function, this can be made common at the controller level by setting it in the constructor.
public function __construct() { parent::__construct(); ... $this->output->set_content_type('application/json'); }
So you just set the output at each function level
$this->output->set_output('{"message":"Failure"}');
It worked for me.
source share