Whats wrong with this custom API class?

Hi, I am starting to develop custom API regarding multiple pieces of information we need.  I wanted to just see if I can get the example on sugar developer site to work, but I got this error. Could not find a route with 2 elements

<?php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

class MyEndpointsApi extends SugarApi
{
   public function registerApiRest()
   {
   return array(
   //GET
   'MyGetEndpoint' => array(
   //request type
   'reqType' => 'GET',

   //set authentication
   'noLoginRequired' => false,

   //endpoint path
   'path' => array('MyEndpoint', 'GetExample', '?'),

   //endpoint variables
   'pathVars' => array('', '', 'data'),

   //method to call
   'method' => 'MyGetMethod',

   //short help string to be displayed in the help documentation
   'shortHelp' => 'An example of a GET endpoint',

   //long help to be displayed in the help documentation
   'longHelp' => 'custom/clients/base/api/help/MyEndPoint_MyGetEndPoint_help.html',
   ),
   );
   }

   /**
  * Method to be used for my MyEndpoint/GetExample endpoint
  */

   public function MyGetMethod($api, $args)
   {
   //custom logic
   return $args;
   }

}

?>

 

 

I am using postman to do the api calls faster. Am I doing this right?

 

Thanks in advance

Parents Reply
  • ./custom/modules/In_locations/clients/base/MyEndpointsApi.php

    should be 

    ./custom/modules/IN_Locations/clients/base/api/MyEndpointsApi.php

    Though I think this was just a typo because your image has the api folder.

    One thing I find is that permissions always mess things up, if your api directory doesn't have the right permissions Sugar won't be able to get in to read it.

    My panacea from sugar root (or other location) on Unix/Linux will set permissions from that location down into the directory structure:

    sudo chown -R  apache:apache *

    sudo find . -type d -exec chmod 775 {} \;

    sudo find . -type f -exec chmod 664 {} \;

     

    where -type d sets permissions on directories

    and -type f sets permissions on files

     

    Until you see your API in the <sugar>/rest/v10/help you can't use it

    FrancescaS

Children