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.

  • Please don't make any changes to the core files.. this is not upgrade save. Always make changes using the custom dataframework. 

  • I wish that was a rule, sadly it's not.  I mean I ended up doing this entirely in custom but I also have at least a dozen files I have to manually upgrade each time because of all the hard coding in the Sugar code base still.  I mean I wanted to make the Field Name Placement default to ABOVE but its all hard coded in the users bean.  Not sure why they did it but the drop down is NOT defined in a language file but hard coded.   In a feature added in v10.  Holy crap batman.

    I mean its a good mantra to live by  but "always" is a pipe dream still.

Reply
  • I wish that was a rule, sadly it's not.  I mean I ended up doing this entirely in custom but I also have at least a dozen files I have to manually upgrade each time because of all the hard coding in the Sugar code base still.  I mean I wanted to make the Field Name Placement default to ABOVE but its all hard coded in the users bean.  Not sure why they did it but the drop down is NOT defined in a language file but hard coded.   In a feature added in v10.  Holy crap batman.

    I mean its a good mantra to live by  but "always" is a pipe dream still.

Children
No Data