Step 1: In a browser, navigate to the online help site at https://hostname/piwebapi/help. Visit the getting started guide that’s hosted as part of the online help, at https://hostname/piwebapi/help/getting-started. Read the first 8 sections (through The Structure of a PI Web API Request).
Step 2: Open https://hostname/piwebapi in another window. You can use this HTML-based interface to browse data exposed by the PI Web API through clicking on the URL links. If you have more than one PI Data Archive and AF Server, pick one to answer the following questions. (If you do not have an AF database, you can import the NuGreen database, available here.)
- What authentication method are you using to connect to PI Web API?
- What is the windows account used to connect to PI Web API?
- What is the version of PI Web API?
- What is the version of the AF Server?
- How many AF Databases are there in the AF Server?
- Pick one element, and pick any attributes using the PI Point Data Reference.
- What is the PI Point configured for this AF Attribute?
- What is the current value (and unit) for this attribute?
PI Data Archive
- What is the server ID of the PI Data Archive?
- Let’s look at the PI Point ‘CDT158’.
- What is the WebId?
- What is the descriptor for the PI Point?
- Get the interpolated data. What is the default start time, end time, and time interval?
Step 3: Apart from navigating through PI Web API by clicking on URL links, let’s construct our own URL and navigate to them on the browser. For the following questions, construct the URL rather than navigating via URL links.
- In PI System Explorer, identify an AF element on your AF database.
- In one call, get the webId of the AF element without first getting the WebId of the asset database. (Hint: GetByPath)
- Get the child attributes of the AF Element with the value type of “double” and sort them in reversed alphabetical order by name.
- Let’s look at the PI Point ‘sinusoid’ (get to the PI Point by path):
- What is the value at midnight?
- Get the archived data over the last year.
- Get the archived data over the last year where the value of ‘sinusoid’ is over 50.
- Get the interpolated data over the last hour in 5-min intervals.
- In one call, get the time-weighted average, range, and maximum value from yesterday’s midnight to today’s midnight.
Step 4: In the above exercise, the browser acts as the client making HTTP GET request to the PI Web API server. Based on the request, the PI Web API server will return a response to the client. We can open up the browser developer tools to take a look at the HTTP request and response.
- Open up the developer tools for your browser (usually by pressing F12).
- Find the webId of an AF database on the browser using GetByPath.
- Look at the request headers:
- What is the request method?
- What is the host for the request?
- What is the authorization header?
- Look at the response headers:
- What is the response status code?
- What is the content-type?
- What is the content-length?