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
  • Hi Nate,

    Can you provide an example of module which it does not work for? And did you test for other modules, does for any of them work?

    I am asking, because some core modules, already extend the ModuleApi. You would find those in the directory modules/<module name>/clients/base/api/

    For those modules, you would have to extend the extended module api, to make sure your api version is the last extension used for the module module's api.

    Example: Contacts already have modules/Contacts/clients/base/api/ContactsApi.php with class ContactsApi extends ModuleApi. For Contacts you would have to extend ContactsApi and not just the generic ModuleApi.

    Hopefully this drives you towards the right direction.

    All the best

    --

    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
  • Hi Nate,

    Can you provide an example of module which it does not work for? And did you test for other modules, does for any of them work?

    I am asking, because some core modules, already extend the ModuleApi. You would find those in the directory modules/<module name>/clients/base/api/

    For those modules, you would have to extend the extended module api, to make sure your api version is the last extension used for the module module's api.

    Example: Contacts already have modules/Contacts/clients/base/api/ContactsApi.php with class ContactsApi extends ModuleApi. For Contacts you would have to extend ContactsApi and not just the generic ModuleApi.

    Hopefully this drives you towards the right direction.

    All the best

    --

    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
No Data