Skip to Content
0
Former Member
Apr 10, 2014 at 12:10 AM

UI5 JSON service authentication

43 Views

Hello,

I am calling a JSON service in UI5,which requires authentication.I have used the below code,but it doesnot work,can you provide some help in resolving the issue.

var aData =

jQuery.ajax({

url: "http://erpapi07.transport.nsw.gov.au:8001/sap/eammob?sap-client=910",

dataType: "json",

xhrFields:

{

withCredentials: true

},

beforeSend: function(xhr) {

xhr.setRequestHeader("Authorization", "Basic " + btoa(USERID + ":" + PASSWORD));

},

success: function(data, textStatus, jqXHR) { // callback called when data is received

alert("sparta");

},

error: function(jqXHR, textStatus, errorThrown) {

alert(jqXHR);

alert(textStatus);

alert(errorThrown);

}

});

Regards

Kaushik