11 Replies Latest reply on Aug 10, 2018 1:47 AM by Dan Fishman

    How to Filter in Web API?

    cageybee

      Hi, we are using Swagger for API access to Pi System. We have to send a JSON request to get the data back. So, our request looks like this:

       

      [
        {
          "AttributePath": "\\\\SERVER\\BREWERY\\CITY\\Packaging\\BL 01\\Filler\\Filler-Crowner|State|Raw Value",
          "StartDate": "8/8/2018 23:00:00-07:00",
          "EndDate": "8/9/2018 07:00:00-07:00",
          "OrderBy": "TimeStamp desc"
        }
      ]
      

       

      My question is this: How do I insert a "Filter" to say, "Only give me records for 2018" in there based on the model below?

       

       

      • Model
      Array[AssetFrameworkValueCriteria {AttributePath (string):

      The asset framework path to the attribute. Will accept wildcards for attribute names. If null or empty string, then everything will be matched. If no wildcards, then an exact match on the query string is performed. Wildcard * can be placed anywhere in the query string and matches zero or more characters. Wildcard ? can be placed anywhere in the query string and matches exactly one character. One character in a set of characters are matched by placing them within [ ]. For example, a[bc] would match 'ab' or 'ac', but it would not match 'ad' or 'abd'. One character in a set of characters are not matched by placing them within [! ]. For example, a[!bc] would match 'ad', but it would not match 'ab', 'ac', or 'abd'.

      ,StartDate (string, optional):

      Date in static mm/dd/yyyy hh:mm:ss or PI Relative format ie *-7d.

      ,EndDate (string, optional):

      Date in static mm/dd/yyyy hh:mm:ss or PI Relative format ie *-7d. If left blank then a single value will be returned instead of a range of values.

      ,Filter (string, optional):

      Filter that satisfies the Performance Equations syntax. More detail can be found athttps://livelibrary.osisoft.com/LiveLibrary/content/en/server-v4/GUID-42D9E42B-6084-4023-829F-919C19A6D45F#addHistory=true&filename=GUID-42D9E42B-6084-4023-829F-919C19A6D45F.xml&docid=GUID-42D9E42B-6084-4023-829F-919C19A6D45F&inner_id=&tid=&query=&scope=&resource=&toc=false&eventType=lcContent.loadDocGUID-42D9E42B-6084-4023-829F-919C19A6D45F

      ,Top (integer, optional):

      The number of records to return

      ,AggregationType (string, optional):

      The aggregation type to perform. Default is None.

      = ['None', 'Interpolated', 'Minimum', 'Maximum', 'Average', 'Sum', 'StandardDeviation', 'Range']stringEnum:"None", "Interpolated", "Minimum", "Maximum", "Average", "Sum", "StandardDeviation", "Range",Interpolationinterval (string, optional):

      The interval to aggregate with. Required when aggregation type is Interpolated.

      ,SelectColumnStatement (string, optional):

      The columns to return. Default is * for all data. Seperate columns by ","

      ,OrderBy (string, optional):

      Determines what values are used to order a collection of records. By default, the order is ascending. Use desc to reverse the order or asc to explicitly set the default. Seperate columns by ",".

      }]