2 Replies Latest reply on Oct 27, 2017 2:33 PM by vkaufmann

    Getting Values of All Children from an Element StreamSet in PI Web API

    Optrix

      I'd like to get the values of all attributes, from all elements under a specific element using the StreamSet controller of the PI Web API.

       

      So in this case, I have a layout similar to the following...

       

      Asset A

          Asset B

              Asset C

              Asset D

       

      And when I ask for the StreamSet for Asset A, I'd like to also see all of the vaues on B, C & D.

       

      I would have thought that searchFullHierarchy would have done this, but it doesn't seem to do anything at all - it doesn't present any new attributes, regardless of where I use it. Accessing the streamset for Asset C shows me all of the attributes of that element, but I can't ask for the attributes of Asset C from Asset B.

       

      If it helps (just in case this is/was a bug), the server version is 2.7.5.7166

        • Re: Getting Values of All Children from an Element StreamSet in PI Web API
          cymerman

          Hi Steven, try to use batch call:

           

          https://{server}/piwebapi/batch

           

          POST request

            "0":{ 

            "Method": "GET", 

              "Resource": "https://{server}/piwebapi/elements/{webId}/elements?searchFullHierarchy=true", 

            }, 

            "1": { 

              "Method": "GET", 

              "ParentIds": [ 

                "0" 

              ], 

             "RequestTemplate":{ 

                "Resource": "https://{server}/piwebapi/streamsets/{0}/value", 

              }, 

              "Parameters":[ 

                "$.0.Content.Items[*].WebId" 

              ]

            } 

          }

          1 of 1 people found this helpful
          • Re: Getting Values of All Children from an Element StreamSet in PI Web API
            vkaufmann

            I think Tomasz provided the correct answer in how to accomplish what you are asking. I would like to point out that the SearchFullHierarchy url parameter doesn't have any effect on elements that are loaded as that should be dictated by the webID you pass in your url. Rather SearchFullHieararchy will control what is loaded in the asset hierarchy on the element you are requesting. Basically, it is a switch to determine if you would like to include child attributes or not in your query.

             

            --Vince