AnsweredAssumed Answered

Queries with PI WebAPI?

Question asked by I.Berry on Nov 13, 2015
Latest reply on Nov 24, 2015 by I.Berry

Hi,

 

I am having some trouble imagining how some common application queries could be implemented using the PI WebAPI. These types of queries are possible with OLEDB or even the discontinued OData interface. But it seems to be difficult to do them with the PI WebAPI. One example is "get the values for a specific attribute(s) from all elements of a certain template".

 

e.g. The current value of the efficiency attribute on all elements of type "Pump"

 

I can see that this could be done as follows

1)

Query with the Search interface to find all Pumps

https://host/piwebapi/search/query?q=afelementtemplate:Pump

 

Or query with the WebAPI to find all pumps:

https://host/piwebapi/assetdatabases/<webID>/elements?templateName=Pump&searchFullHierarchy=true

 

2)

For each of the pumps, need to find the WebID of each of the efficiency attribute

 

This is a HTTP GET for each pump

https://HOST/piwebapi/elements/<webID>/attributes?nameFilter=Efficiency

 

3)

Build a URL using the WebIDs from  that will return all the current values for each efficiency attribute with one request (I believe this is possible in PI WebAPI 2015R2)

 

 

My question is: Is this the best way to do it with PI WebAPI, or is there a more efficient way?

 

Many Thanks!

Ivan

Outcomes