SugarREST API returns a entry_list even when the record is not found
Calling the REST API get_entry for a record that does not exist, I would expect that the service returns a fault instead of a entry_list. See example shown below:
{entry_list: [{id: "bf700a80-6cdf-6587-d548-4d2d74f47d6",module_name: "Contacts",name_value_list: [{name: "warning",value: "Access to this object is denied since it has been deleted or does not exist"},{name: "deleted",value: "1"}]}],relationship_list: []}
Source 1. JSON returned when th record is not found.
My proposal is that the service returns a fault when the event occurs: records not found. See the example of the desired fault follows.
{name: "Record not found or deleted",number: $error_number,description: "Access to this object is denied since it has been deleted or does not exist"}
Source 2. Desired fault when record not found or deleted.
Managing abnormal situations through fault messages, simplifies error handling client side. See the output of a Java client Rest in case of error in the login process.
Following is an example of Java code that implements a client Rest managing all the fault the same way.
try {SugarCRMInterface crmRestIf = new SugarCRMRestClient();// Try loginSystem.out.println("Try login...");UserAuthLogin userAuth = new UserAuthLogin( new UserAuth("wil","18218139eec55d83cf82679934e5cd75","1.0"));EntryValue response = crmRestIf.login(userAuth, "RESTFulClient-1.0", null);...// Get entrySystem.out.println("Get entry...");EntryResult contact = crmRestIf.getEntry(response.getId(), "Contact", "bf700a80-6cdf-6587-d548-4d2d74f47d6c", null, null);...} catch (FaultException fex) {System.out.println("Code: " + Integer.toString(fex.getCode()));System.out.println("Descrition: " + fex.getDescription());System.out.println("Detail: " + fex.getDetail());System.out.println("Detail Message: " + fex.getMessage());}
Source 3. Example of Java code that handles situations Fault.
The reference version is the 6.1 Community Edition, version 3 of the REST API.







