0

I am trying to login to SugarCRM using jQuery and Sugar REST API. I have no luck so far. Following is the code snippet:

            var returnVal = $.ajax(,{
                type: "POST",
                url: "http://127.0.0.1:101/sugarcrm/service/v4/rest.php?method=login",
                dataType: "json",
                method: login,
                success: function(response){
                    alert("Done it");
                },
                data: data1,
                failure: failedAjax
            });

1 Answers1

2

Try this snippet and see if it works better....

$.ajax({
  type: "POST",
  url: "http://127.0.0.1:101/sugarcrm/service/v4/rest.php",
  data: { method: "login", input_type: "JSON", response_type: "JSON", rest_data: data1 },
  dataType: "json"
  success: function(result){
      if ( result.id ) {
          alert("Success! Session ID is " + result.id);
      }
      else {
          alert("Error: " + result.name + " - " + result.description);
      } 
      }
  },
  failure: failedAjax
});
dwerner
  • 6,462
  • 4
  • 30
  • 44
jmertic
  • 2,208
  • 1
  • 13
  • 8