By default, Magento returns XML format when you try to access REST API resources. For example :
You try to access REST url to get product’s information of this site : http://localhost/magento/api/rest/products

It will return in XML format.But some cases, other developers want you to send them JSON format instead of XML.

Solution for it is you have to override the METHOD getAccepTypes() in /app/code/core/Mage/Api2/Model/Request.php

to return JSON format by replacing “return array_keys($orderedTypes);”  to  “return array_keys(array(“application/json” => 1));” .

This will help you to Response of REST API in JSON format by default in Magento

There are two ways to do it:

1/You could change it in core file /app/code/core/Mage/Api2/Model/Request.php  : NOT RECOMMENDED
2/ For more professional way, you should create small extension to override Rest Request Model. : RECOMMENDED
Here is how :

2.1/ Declare new module : Create app/etc/modules/Gurutheme_RestConnect.xml


2.2/ Create /app/code/local/Gurutheme/RestConnect/etc/config.xml with the following content :




As you can see from above code :
We rewrited Mage/Api2/Model/Request by Gurutheme_RestConnect_Model_Api2_Request


2.3/ Create /app/code/local/Gurutheme/RestConnect/Model/Api2/Request.php


That’s done. Hope it helps.