AnsweredAssumed Answered

PI Web API: Access Issue

Question asked by Doddabasappa Champion on Mar 20, 2017
Latest reply on Apr 11, 2017 by gregor

Hi,

 

Developed web application where making ajax call to PI Web API as below. PI Web API configuration is set to basic authentication, hence I am passing credentials as required. 

 

function MakeAjaxRequest(type, url, SuccessCallBack, data) {
    $.ajax({
        type: type,
        url: url,
        cache: false,
        async: true,
        data: data,
        contentType: "application/json",
        beforeSend: function (xhr) {
            xhr.setRequestHeader('Authorization', make_base_auth(username, password));
        },
        success: SuccessCallBack,
        error: (function (error, variable) {
            alert('There was an error with the request');
        })
    });
}

 

The issue is, when I run application for the first time, will be encountering access denied issue as show below. But if I run application after connecting to base PI web API (https://server/piwebapi/) by providing credentials in browser, it will works fine.

 

IE Web API.png

 

What could be the issue?

Outcomes