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 = "$filter=Id%20eq%2022233";
url: url,
type: "GET",
dataType : 'jsonp',
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) {
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