AnsweredAssumed Answered

All Get requests are having the point name and database name changed to unkown when going to the server.

Question asked by jrog091661 on Sep 8, 2017
Latest reply on Sep 18, 2017 by Marcos Vainer Loeff

I will start off by saying that I am using the methods mentioned here in this blog for connecting to the database:  Announcing PI Web API client library for jQuery using Swagger

 

When I try the included files, it works somewhat fine.  The server is detected as existing and so is the point.  Image 1 displays what I see when I use the example script but obviously with my server name.  Image 2 shows the request is successful (The two 404 errors are because we have 2 types of authentication enabled, disabling the one causing the errors still results in the problem we are seeing).  So, when I try to recreate what the example is doing with this code here, the error still results, the call has the point and database as undefined, very similar in face to the 404 errors featured on image 2.  Here is the link that gets called to.  https://bfcrpiarc2/piwebapi/points?path=%5C%5Cundefined%5Cundefined  As I said, I have already tried disabling the authentication methods that are not being used for this, as well as hard coding in the server name, point name, and even the ID.  The script may not be accomplishing what I want it to anyways, but if the call was working correctly, troubleshooting that myself would be rather trivial.  For now, the code was simply written such that data could be returned and tested.

 

  <script src="js/jquery-3.1.1.js"></script>
    <script src="js/jquery-piwebapi.js"></script>
    <script src="js/pi_data_result.js"></script> //This is the original example, same result happens rather or not its scripts are included and used over rewriting them below
    <script src="../../static/js/jquery-3.2.1.min.js"></script>
    <script src="../../static/js/bootstrap.min.js"></script>

  <script>
  //Structure for this function:
  //  StreamApi.prototype.getRecorded = function (webId, boundaryType, desiredUnits, endTime, filterExpression, includeFilteredValues, maxCount, selectedFields, startTime, timeZone, extraHttpRequestParams)
  //Leave undesired fields as null
    function GetPiData(piPointName,piServerName,startTime,endTime){
      var piwebapi = new PIWebApi("https://bfcrpiarc2/piwebapi", true);
      piwebapi.point.getByPath('\\\\' + piServerName + '\\' + piPointName, null, null).then(function (response) {
      var value=piwebapi.stream.getRecorded(response.data.WebId, null, null, endTime, null, null, null, null, startTime);
      });
      return value;
    }
    //This function is called when the webpage is loaded and fills the table with data for the 19 points and each hour of the day
    function populateTables(){
      var i;
      //array that will be used to store the json objects for each of the 19 data points that will be used
      var dataPoints=new Array(19);
     //We use a for loop to loop through each hour to avoid copy pasting
      for(i=0;i<24;i++){
        //The date was hardcoded for now for testing purposes, I have also tried the standard *-1h and * from the examples but error still occurs   
        dataPoints[0]=GetPiData("XX:FRNPRM.IN","bfcrpiarc2","2017-09-07T00:00:00Z","2017-09-07T00:59:59Z")
      }
    }
  </script>

Attachments

Outcomes