0

I have a small assignment to fetch customer account information by consuming connect mobile API [enqTcibAcctDetailss()] through JavaScript/ AngularJS. I have tried different ways but ended up on a conclusion that I am not able to set header values in my HTTP GET request.

I have tried setting header values using J2EE and it works for me. I can see the values in the header. But the environment where I want to consume web service only allows web service consuming in scripting language e.g. JavaScript, AngularJS.

I am wondering if someone has any working sample in JavaScript to consume any connect mobile API. In the browser, I can see my request is not carrying any header value. The way I am trying to set values in the header is following;


var url = "http://13.80.22.62:9026/TCMBCommon-iris/TCMBCommon.svc/GB0010001/enqTcibAcctDetailss()?$filter=Id%20eq%2022233";
$("#button").click(function(){
$.ajax({
url: url,
type: "GET",
dataType : 'jsonp',
crossDomain:true,
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa("MyUserName" + ":" + "MyPassword"));
},
// I have also tried in this way but it is not setting the values in header.
// headers: {
// Authorization: "Basic " + btoa("MyUserName" + ":" + "MyPassword"),
// Accept : "application/json+hal"
// },
success: function (result) {
alert($.parseXML(result));
},
error: function (textStatus, errorThrown) {
alert(textStatus.toString + "\n" + errorThrown);
}
});
});

I have read in a blog the problem might be at server side which is not allowing to set any value in request header but I am not sure about it.

Any help/ clue will be appreciated.

Abdul Waheed asked