Suppose you encounter a "duplicate entry" error while trying to retrieve an order using the REST API in Magento. In that case, it means that there is already an entry with the same identifier in the system. This can occur if you're trying to create a new order with an already-used identifier by an existing order. You must ensure each order has a unique identifier to resolve this issue. You can provide a different identifier for the new order or update the existing one with a unique identifier. You will prevent the "duplicate entry" error and allow you to retrieve orders successfully using the REST API.
We will learn in this topic how to solve the REST API bug of Magento 1 while getting the order with Order REST API.
This bug is inside the "Mage_Sales_Model_Api2_Order_Rest" class, and this is an abstract class, so we can't override this via the Magento module override feature in config.xml
We can do this using the "local" code pool of Magento.
We must copy the "Mage_Sales_Model_Api2_Order_Rest" class into Magento's app/code/local/ folder.
Add the following line to the file.
$collection->getSelect()->group(‘main_table.entity_id’);
Here is the complete source of the file