Use Case

This article describes how to use either chrome or IE, or another API tester application to query the Bazefield API.  It is suggested to read  Quick Start: Bazefield API prior to this, as well as Quick Start: Tag Manager 


Background

Often it may be advantages for super-users to integrate Bazefield data directly into other third party clients and applications (like Matlab, Power BI, Python, etc.).  Prior to this, however, it is useful to use a web browser or third party API application to test out various queries to make sure the data returned is consistent with what is being asked for.  This article starts with a procedure to simply query the last known value of a given set of tag(s) within Bazefield using both chrome (or IE), and Postman.  Chrome and Postman serve as good testing tools to ensure the queries are working accurately before formerly embedding the Bazefield api in a third party application like Matlab.  This Process can be repeated for all Bazefield API requests.


Prerequisites

While a simple web browser can be used for testing API calls, this specific article also references a third party API development tool called Postman (https://www.getpostman.com/downloads/) which is free to download.  Postman helps simplify the API route generation process.  This article will show how to test various API routes using a simple chrome browser as well, though.


Attached to this KB article is a Postman template file, which can be imported directly into the user's version of Postman.  It has many relevant queries that can be used as templates for the user to define their own requests.


Steps:  Reading Last Known Value


  • For reference, have open the Bazefield API homepage (https://<YourBazefieldSubdomain>.bazefield.com/Bazefield.Services/api ) home page in a web browser, and go to the ReadMeasurements/JSON page


 




  • Examine the function call Input and Outputs.  The ReadMeasurements Function is routed to the https://<YourBazefieldSubdomain>.bazefield.com/Bazefield.Services/api/measurements/{Keys} url.  Here {Keys} is a user-defined variable referencing the tag name(s) desired by the user.



  • Find a tag or tags you would like to send as the {Keys} for the function.  This can be done using the Tag Manager application.  The following example will return the most recent value of the of the WFU-T01-Windspeed tag (Turbine 1 WindSpeed).  


            Using Chrome or IE:  

Enter the full URL in the web browser.  If the user has already logged and authenticated in the portal (demo.bazefield.com in this example), then no authentication needs to be passed with the call.

            The optional parameter format=json query addition is additionally helpful for many real-world applications to output the data in a JSON array.


Using Postman:  

First enter the user API token into the Authorization tab.  The user token can be found from the User Manager application.  Quick Start: Bazefield API contains the instructions to generate a user API token

    




Next enter in the same url in the "Params" tab as what was done in chrome/IE.  A preview of the data will be provided in the "Body"




Product Environment and Version

Bazefield Portal 8.0.19