4 Replies Latest reply on Nov 18, 2016 7:23 AM by abilbaod

    Error using JSONPath in PI Web API POST batch

    abilbaod

      Hi, I've just started using the PI Web API in order to replace some code that uses PI SDK with PI Web API calls, and have found a problem while testing a POST batch request. I've used the example provided at https://techsupport.osisoft.com/Documentation/PI-Web-API/help/controllers/batch/actions/execute.html as a template to generate this request:

       

      {

        "GetPoints": {

          "Method": "GET",

          "Resource": "https://WEB_API_SERVER/piwebapi/points/multiple?path=\\\\PI_ARCHIVE_SERVER\\point1&path=\\\\PI_ARCHIVE_SERVER\\point2&selectedFields=Items.Object.WebId"

        },

        "GetDescriptions": {

          "Method": "GET",

          "Resource": "https://WEB_API_SERVER/piwebapi/points/{0}/attributes/descriptor?selectedFields=Value",

          "Parameters": [

            "$.GetPoints.Content.Items[*].Object.WebId"

          ],

          "ParentIds": [

            "GetPoints"

          ]

        }

      }

       

       

      What I'm trying to get is the "descriptor" attribute of multiple PI points using a single HTTP request, but although the first request returns values, the second request of the batch does not seem to like the JSONPath expression I'm using. This is the response I'm getting:

       

      {

        "GetPoints": {

          "Status": 200,

          "Headers": {

            "Content-Type": "application/json; charset=utf-8",

            "Content-Length": "227"

          },

          "Content": {

            "Items": [

              {

                "Object": {

                  "WebId": "P0li5DzIj_NEaI77UxCPU68A6IEAAAU1NCSU8wNVBJMDEuUk0uR1IuUkVQU09MWVBGLkNPTVwzM1RJMTAzMw"

                }

              },

              {

                "Object": {

                  "WebId": "P0li5DzIj_NEaI77UxCPU68A54EAAAU1NCSU8wNVBJMDEuUk0uR1IuUkVQU09MWVBGLkNPTVwzM1RJMTAzMg"

                }

              }

            ]

          }

        },

        "GetDescriptions": {

          "Status": 400,

          "Headers": {},

          "Content": "Invalid parameter: $.GetPoints.Content.Items[*].Object.WebId"

        }

      }

       

      The problem seems to be the "Items[*]" in the parameter, because if I replace it with "Items[0]" I get the correct value of the descriptor for the first point. Is there someting wrong with the JSONPath expression?. Could I get the same information using an alternate HTTP batch request?.

       

      Thanks,

      Álvaro.