Skip to content

Instantly share code, notes, and snippets.

Created June 28, 2019 01:11
What would you like to do?
/* File: ./custom/clients/base/api/MyCustomApi.php */
class MyCustomApi extends SugarApi {
public function registerApiRest() {
return array(
'myCustomMethod' => array(
'reqType' => 'GET',
'path' => array('customEndpoint'),
'pathVars' => array(),
'method' => 'myCustomMethod',
'shortHelp' => 'This is a custom endpoint.',
'longHelp' => '',
public function myCustomMethod($api, $args)
//Some code
//Here we raise the exception with our custom error message
throw new SugarApiExceptionMissingParameter('You are missing a parameter required for properly invoking this endpoint.');
//the rest of your code for your custom method
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment