FuelPHP unexpectedly returns Arr instead of data accessing REST controller with no format specified

When working with the REST Controller in FuelPHP and accessing it from your browser you see “Arr” when a format is not specified in the URL instead of the expected data in your default format. This is because of a setting in the rest.php config file (fuel/core/config/rest.php OR /fuel/app/config/rest.php).

Change:

<pre>’ignore_http_accept’ => false,</pre>

to:

<pre>’ignore_http_accept’ => true,</pre>

 

This is faster and will make your default the default format as expected.  If the client needs the data in another format they can specify it in the URL.

2 thoughts on “FuelPHP unexpectedly returns Arr instead of data accessing REST controller with no format specified”

  1. Hey Dustin! What a funny coincidence that I stumbled across this post in search for a fix for this issue! Looks like Fuel made the following change in 1.2.*:

    if (\Input::server(‘HTTP_ACCEPT’) and \Config::get(‘rest.ignore_http_accept’) !== true)

    (it used to be === true)

    I wonder if this is a core bug?

    Thanks!!

Leave a Reply

Your email address will not be published. Required fields are marked *