AnsweredAssumed Answered

Getting Event Frame Attribute Values via PIWebAPI

Question asked by ian.d.gore on Jan 25, 2019
Latest reply on Jan 30, 2019 by ian.d.gore

Hi,

 

I'm setting up a batch query in PIWebAPI to read all the attribute values for all event frames matching certain criteria.  So far I've come up with this - which works and is usable.

{

"Database": {

"Method": "GET",

"Resource": "<API_URL>/assetdatabases?Path=<DB_PATH>&selectedFields=WebID",

"Headers": { "Cache-Control": "no-cache" } }

,

"EventFrames": {

"Method": "GET",

"Resource": "<API_URL>/eventframes/search?databaseWebID={0}&query=TemplateName:\"Data Event Frame\" IsAcknowledged:false&selectedFields=Items.WebID;Items.StartTime;Items.EndTime;Items.Links.Attributes",

"Parameters": [ "$.Database.Content.WebId" ],

"ParentIds": [ "Database" ] }

,

"Attributes": {

"Method": "GET",

"RequestTemplate": { "Resource": "{0}?selectedFields=Items.Name;Items.WebID" },

"Parameters": [ "$.EventFrames.Content.Items[*].Links.Attributes" ],

"ParentIds": [ "EventFrames" ] }

,

"Values": {

"Method": "GET",

"RequestTemplate": { "Resource": "<API_URL>/streams/{0}/value" },

"Parameters": [ "$.Attributes.Content.Items[*].Content.Items[*].WebId" ],

"ParentIds": [ "Attributes" ] }

}

 

I have a few questions about this:

  1. Is there a better way of doing it? Are there any shortcuts I can use?
  2. The "Values" query ends up returning a single array of values - so if 3 event frames are found each with 7 attributes I'll get 21 values in an array.  To re-construct the event frames (eg into a table for a grid display), I'll need to loop down the Event Frames query to construct the "rows", then loop down the Attributes query to construct the "columns" and then loop round the values (allowing for the number of attributes in the event frame) to construct the "cells". Is there a better way to construct the query so it's easier to reconstruct the event frames?

Outcomes