I'm working with the REST_Controller extended CI_Controller and for some reason my requests are all coming back with a content-type of text/html instead of json. In my config, I have json set as the default format:
$config['rest_default_format'] = 'json';
My results are coming back as JSON, but the content-type isn't being set. Can anyone help with what I'm missing?
I'm not sure if the config sets the format. But a simple work around might be just to use the output class to set the header content type, something like:
$this->output
->set_content_type('application/json')
->set_output(json_encode(array('foo' => 'bar')));
(Taken from the manual: here)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With