Best way to log API calls that create records

Many of our records are created via an API call from an external source.  Is there a way I can log those calls so I can see what was sent in via the API versus what is in the record now.  I just want an irrefutable way to see what they are sending into the system.

I need to see all the data included in the POST.

Parents
  • If you have access to core code you can add logging to ~/include/api/RestService.php just below the comment that has "// This looks like the post contents are JSON".

    Something like:

                        // This looks like the post contents are JSON
                        // Note: If we want to support rest based XML, we will need to change this
    
    @$GLOBALS['log']->fatal("POSTED DATA:$postContents");

    Add extra code to filter out unwanted requests based on $this->getRequest()->getRequestURI().

    If it is sugarondemand then you may be able to create a ~/custom/include/api/RestService.php, derive from the core code RestService and override getRequestArgs(). I've not tried that though.

  •  ~/custom/include/RestService.php ist an add-on file wich is called before the REST service functions are executed.

    Code of ~/api/rest.php:

    ob_start();
    chdir(dirname(__FILE__).'/../');
    define('ENTRY_POINT_TYPE', 'api');
    require('include/entryPoint.php');
    SugarAutoLoader::load('custom/include/RestService.php');
    $restServiceClass = SugarAutoLoader::customClass('RestService');
    
    global $service;
    $service = new $restServiceClass();
    $service->execute()

    So you can add logging of incoming data to such a custom file without touching the core files.

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • Oh I like this idea, might work better than the logic hook.

Reply Children
No Data