1

Magento CE-1.9.2.4

I am trying to use the REST API and when accessing (for example) http://my-domain.com/api/rest/customers the response is the following:

<?xml version="1.0"?>
<magento_api>
  <messages>
    <error>
      <data_item>
        <code>403</code>
        <message>Access denied</message>
        <trace>#0 /var/www/html/my-domain.com/app/code/core/Mage/Api2/Model/Server.php(106): Mage_Api2_Model_Server-&gt;_allow(Object(Mage_Api2_Model_Request), Object(Mage_Api2_Model_Auth_User_Guest))
#1 /var/www/html/my-domain.com/api.php(73): Mage_Api2_Model_Server-&gt;run()
#2 {main}</trace>
      </data_item>
    </error>
  </messages>
</magento_api>

which is good, I mean the message is Access denied.

Is there a way not to print (hide) the <trace> tag?

0

you get a trace in your REST API return error if your store is set to developermode (Magento 1.9.x). So you probably have something like this in your index.php file:

Mage::setIsDeveloperMode(true);

In a live environment no trace will be send along with the error message.

But just in case you want to hide the trace in your developer mode store in, for instance, a custom REST API function, you could for instance add this:

protected function _create($orderline)
...
if (!$results['success']) {
  Mage::setIsDeveloperMode(false);
  return $this->_critical($results['message'], $results['code']);
  Mage::setIsDeveloperMode(true);
...

Sometimes a bit handy when you want to develop but the rest api consumer should not be able to see the trace... So remove the setIsDeveloperMode lines in a live environment :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.