AnsweredAssumed Answered

Error in loop in PI UFL Connector configuration

Question asked by tombayu.hidayat on Dec 19, 2019
Latest reply on Jan 9, 2020 by mhruzik

Hello everyone,

I am having a trouble in writing the ini file during the configuration of PI UFL connector. I am streaming a data from a REST API, and typically the API returns a JSON with this structure. I attach the complete data below.



What I want to do with the data is as follows:

I want to parse the [traces] part of the data. For every object in [traces]/[Object]/[data], I’d like to take the create a point. The name of the point should contain the [applicationId], [type], and the [position]; and the value of each point is derived from the [value] of each [traces]/[Object]/[data]. If my explanation here is confusing, maybe the code I have so far would explain it better:


FIELD(1).NAME = "TagName"
FIELD(2).NAME = "Value"
FIELD(2).TYPE = "Number"
FIELD(3).NAME = "TimeStamp"
FIELD(3).TYPE = "DateTime"
FIELD(3).FORMAT = "yyyy-MM-ddThh:mm:ss.nnnZ"
FIELD(4).NAME = "Track"
FIELD(5).NAME = "Parameter"
FIELD(6).NAME = "Position"

MSG(1).NAME = "Traces"

Traces.FILTER = C1 == "*"


FOREACH (JsonGetItem(__MESSAGE, "traces[]")) DO


Track = JsonGetValue(__ITEM, "applicationId")
Parameter = JsonGetValue(__ITEM, "type")


TimeStamp = JsonGetValue(__ITEM, "time")

   FOREACH (JsonGetItem(__ITEM, "data[]")) DO

   Position = JsonGetValue(__ITEM, "position")
   Value = JsonGetValue(__ITEM, "value")
   TagName = Track + "/" + Position + "/" + Parameter
   StoreEvent(TagName, , TimeStamp, Value)



Running the ini file somehow always stops in the first point; only one point is created. When the loop proceeds to the next [position], it returns this error message:


Severity: Error
Timestamp: 12/19/2019 14:18:37.028
Message: [test] Error parse line ({<the data...>}): [1, [Line 26] [JsonGetItem] [Error] [Json Extraction] data not found.]

The error points out to the FOREACH (JsonGetItem(__ITEM, "data[]")) DO part of the code, indicated in bold above.


I have two questions:

  • Why does the loop cannot proceed to the next [position], and how do I solve it?
  • How do I get the full [position] to be included in the tag name? My code could only take it until the dot; the number after the dot is excluded.


Any help is appreciated!