2 Replies Latest reply on Sep 18, 2017 9:43 PM by Marcos Vainer Loeff

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


      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>
        //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
              //The date was hardcoded for now for testing purposes, I have also tried the standard *-1h and * from the examples but error still occurs   
        • Re: All Get requests are having the point name and database name changed to unkown when going to the server.

          Hi John,


          It looks like it's line 13 that is failing but I'm having trouble replicating the issue.  I don't think it has anything to do with security - it's just that the parameters are not being read into the GetByPath method. 


          It seems like you tried this but I'm not positive, could you replace "'\\\\'+piServerName + '\\'+piPointName" with "\\\\servername\\sinusoid" for testing?

          1 of 1 people found this helpful
          • Re: All Get requests are having the point name and database name changed to unkown when going to the server.
            Marcos Vainer Loeff

            Hello John,


            Here are my suggestions for you:


            1)Download this GitHub repository and test the example from the VersionWithClientLibrary folder, which uses the jquery-piwebapi.js library. If there isn’t any misconfiguration, the web app will work fine.



            2)There are some issues with your code:

            • The PI Web API methods are async methods which returns promises not objects. This is why you must get the response using the following pattern:


            piwebapi.point.getByPath('\\\\' + piServerName + '\\' + piPointName, null, null).then(function (response) { 
            • There are bulk methods to get the PI Point webIds and their compressed values (also in bulk).


            This is code snippet that might help you:


                piwebapi.point.getMultiple(true, 'All', ['\\\\' + piServerName + '\\sinusoid', '\\\\' + piServerName + '\\cdt158']).then(function (response) {
                    var webIds = [];
                    for (var i = 0; i < response.data.Items.length; i++) {
                    piwebapi.streamSet.getRecordedAdHoc(webIds, null, "*", null, true, 1000, null, "*-3d", null).then(function (response) {
                    }, function (error) {
                }, function (error) {


            Let me know if this works!

            1 of 1 people found this helpful