2. Override registerApiRest() and add your API customization.
public function registerApiRest()
{
return array(
'MyGet' => array(
'reqType' => 'GET',
'path' => array('Accounts', 'GetExample'),
'pathVars' => array('', ''),
'method' => 'MyGet',
'shortHelp' => 'An Example of a GET endpoint',
'longHelp' => '', )
);
}
3. Add your MyGet method
public function MyGet($api, $args){
return "Hello World!";}
4. Final Code
<?php
if(!defined('sugarEntry') ||
!sugarEntry) die('Not A Valid Entry Point');
class MyEndpointsApi extends SugarApi
{
public function registerApiRest()
{
return array(
'MyGet' => array(
'reqType' => 'GET',
'path' => array('Accounts', 'GetExample'),
'pathVars' => array('', ''),
'method' => 'MyGet',
'shortHelp' => 'An Example of a GET endpoint',
'longHelp' => '',
)
);
}
public function MyGet($api, $args)
{return "Hello World!";}
}
5. Test your API call (I suggest POSTMAN for Chrome)
No comments:
Post a Comment