Extending the moduleapi endpoint does not work

if you put this in custom/clients/base/api/CustomModuleApi.php
<?phpif(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');require_once("clients/base/api/ModuleApi.php");class CustomModuleApi extends ModuleApi
{
    public function registerApiRest()
    {
        return parent::registerApiRest();
    }    public function retrieveRecord(ServiceBase $api, array $args)
    {
        $result = parent::retrieveRecord($api, $args);        //append the current timestamp
        return $result . ' ' . time();
    }
}
it is supposed to intercept the GET method for any module with an id request, although it does not.The ping module seems to work though.  If you put this in custom/clients/base/api/CustomPingApi.php
<?phpif(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');require_once("clients/base/api/PingApi.php");class CustomPingApi extends PingApi
{
    public function registerApiRest()
    {
        //in case we want to add additional endpoints
        return parent::registerApiRest();
    }    //override to modify the ping function of the ping endpoint
    public function ping($api, $args)
    {
        $result = parent::ping($api, $args);        //append the current timestamp
        return $result . ' ' . time();
    }
}
it works perfectly...  can anyone tell me why the ping works and the module does not?  Am I missing something?
Parents
  • Lets start with Manufacturers, I don't see any extension in modules/Manufacturers/clients/base/api nor do I see anything in custom/modules/Manufacturers/clients/base/api, yet the above code does not run...

  • What about if you change the code to this and repair?

    <?php

    class CustomModuleApi extends ModuleApi
    {
        public function registerApiRest()
        {
            return parent::registerApiRest();
        }

        public function retrieveRecord(ServiceBase $api, array $args)
        {  
            $GLOBALS['log']->fatal('CustomModuleApi->retrieveRecord called');
            return parent::retrieveRecord($api, $args);
        }
    }

    Do you see the log entry on the sugarcrm.log when leveraging the Manufacturers single record retrieve api?

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

Reply
  • What about if you change the code to this and repair?

    <?php

    class CustomModuleApi extends ModuleApi
    {
        public function registerApiRest()
        {
            return parent::registerApiRest();
        }

        public function retrieveRecord(ServiceBase $api, array $args)
        {  
            $GLOBALS['log']->fatal('CustomModuleApi->retrieveRecord called');
            return parent::retrieveRecord($api, $args);
        }
    }

    Do you see the log entry on the sugarcrm.log when leveraging the Manufacturers single record retrieve api?

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States

Children