AnsweredAssumed Answered

Cannot retrieve records from a custom made module in REST API v10

Question asked by Darrell Cunningham on Nov 30, 2016
Latest reply on Jun 26, 2017 by Pat Pawlowski

Hi all,

 

I'm really new to REST API for Sugar CRM in fact I'm really new to sugar crm.  I am having a problem with a PHP.  I am trying to retrieve records from a custom module I created in Sugar through the module builder.  I have deployed it and added all my records to it but when I try to access it through the Rest API it wil not find it.  I get

 

object(stdClass)#17 (2) {
  ["error"]=>
  string(9) "no_method"
  ["error_message"]=>
  string(38) "Could not find a route with 1 elements"
}

 

I'm trying to use GET in my php script.  I've already obtained the OAUTH token and it works if I use one of the sugar modules like Accounts. The custom module is called "GROUPS" in the package "DHP".

 

Here is the code I use.  If I change the $module variable to "Accounts"  or "Contacts" it works.  But If I try "GROUPS" or "DHP_GROUPS" I get the above error.  Am I missing something?

 

$module="GROUPS"

$instance_url = "https://dhptraining.sugarondemand.com/rest/v10";

 

$token = $this -> checkdbasetoken();    //get the token info from the database where the current token is stored

$oauth_token = $token['access_token']//set the token

$fetch_url = $instance_url . "/$module";

$fetch_request = curl_init($fetch_url);

curl_setopt($fetch_request, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);

curl_setopt($fetch_request, CURLOPT_HEADER, false);

curl_setopt($fetch_request, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($fetch_request, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($fetch_request, CURLOPT_FOLLOWLOCATION, 0);

curl_setopt($fetch_request, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "oauth-token: {$oauth_token}"));

//execute request

$fetch_response = curl_exec($fetch_request);

 

//decode json

$fetch_response_obj = json_decode($fetch_response);

echo "<pre>";

var_dump($fetch_response_obj);

echo "</pre>";

 

Outcomes