Gerardo Garcia Lima

API call returns null

Discussion created by Gerardo Garcia Lima on Aug 4, 2016
Latest reply on Aug 4, 2016 by Gerardo Garcia Lima

Hi everyone,


My SugarCRM is 7.5


I have an API call but the return is always null. On the API itself I logged the return at the end and it has the STRING I want back to the JS but somehow when it get to the success the variable is null.


var url = app.api.buildURL('/string/' + value);'GET', url, null,{
    complete: function(complete) {
        console.log('complete', complete);
    success: function(success){
        console.log('success', success); //null
    failure: function (failure) {
        console.log('failure', failure);
    error: function (error) {
        console.log('error', error);


After the execution on the success is returning null, the complete also has null on the responseString.


function API ($vars)
    //Lost of code

    return $html_code;


In the PHP I log the string before the return to the controller and it has the result i want to retrieve.


I even log the include/api/RestService.php 


public function execute()

    $GLOBALS['logic_hook']->call_custom_logic('', "before_respond", $this->response);
    $GLOBALS['log']->fatal(print_r($this->response, true));

In the response object I can see the string that i want to retrieve.


I hope someone know whats happening. 


Thank you very much!