401: Unauthorized Error Using AJAX Call - Bearer Token

34 views Asked by At

AM getting error as 401 unauthorized while calling AJAX call... When i debug error throws in setRequestHeader.

$.ajax({
    type: "GET",
    xhrFields: {
        withCredentials: true
    },
    crossDomain: false,
    beforeSend: function (d, c) {
        d.setRequestHeader("Authorization", "Bearer " + IportalauthContext.GetOauthToken(iPortal.global.common.DefaultResource))
    },
    url: b,
    dataType: "json",
    success: function (c) {
        renderFooter(c.value[0], pageName);
        fOpenHeight = fOpen.outerHeight();
        $(".tOpen").css("bottom", fOpenHeight - 27);
        fOpen.addClass("fOpen");
        fOpen.removeAttr("style")
    },
    error: function (d, c) {
        console.log("Error")
    } })

enter image description here

Please provide me a suggestion or solution to track this issue.

0

There are 0 answers