AnsweredAssumed Answered

PIWebAPI from Safari on iPad

Question asked by neilg on Aug 7, 2016
Latest reply on Aug 8, 2016 by neilg

Hi All,


I am trying to call PIWebAPI from an iPad (at this stage) using basic authentication. The instance of PIWebAPI is setup with Basic authentication only at this point.


From JavaScript I am making an ajax call to the PIWebAPI instance and I pass in the correct Authentication header but the call does not return successfully. It always ends up in the error handler and provides a status of "error". The xhr object does not appear to have more details when running from the iPad from what I can tell but this is a different point.


I have tried various combinations of parameters but nothing seems to succeed for e.g. no datatype option, no jsonp option, withCredentials true and false and without it as well, no headers, etc. It always ends up in the error callback and the status says "error". When I try to access the properties of the xhr object in the error callback I get undefined. Note the same code below works from Chrome on my desktop.


Has someone done this with success before? What am I doing wrong?


JavaScript code (jQuery version 2.1.4):


function successCallBack(Response, data, xhr) {

// Make a call to PIWebAPI
function errorCallBack(jq, status) {
    try {
        alert("ERROR: " + status + " ");
    } catch (e) {
        alert("Exception: " + e.message);
function processJsonContentForceBasic(type, data, url, successCallBack, errorCallBack) {
    return $.ajax({
        type: type,
        data: data,
        dataType: 'json',
        jsonp: false,
        headers: {
            "Content-Type": "application/json; charset=utf-8",
        url: url,
        crossDomain: true,  
        xhrFields: { withCredentials: true },  
        beforeSend: function (xhr) {
            xhr.setRequestHeader("authorization", "Basic [base 64 hash of username and password]");
        success: function (Response, textStatus, xhr) {
            if (successCallBack != null) { successCallBack(Response, data, xhr); }
        error: function (jq, status) {
            if (errorCallBack != null) { errorCallBack(jq, status); }
function Authenticate() {
    var url = "";
   var callPIWebAPI = processJsonContentForceBasic('GET', null, url, successCallBack, errorCallBack);