AnsweredAssumed Answered

Extending the moduleapi endpoint does not work

Question asked by Nate Morris on Jul 1, 2020
Latest reply on Jul 2, 2020 by Nate Morris
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?

Outcomes