0

Web Write API - Postman Example (version 23)

The following article demonstrates how to set up an environment within Postman (v9.09) for testing Canary's web write API. Postman is a platform designed for building and using API's. For more information on Postman and where to download it, visit https://www.postman.com/.

DISCLAIMER: The API requests found within this collection are configured to send data over the anonymous (http) API endpoint (55253) within the Sender on the local machine. Admins should use discretion when enabling the anonymous port on a production environment and allowing the ANONYMOUS LOGON.

The configuration can be modified to connect to the secure port (55254) and use https as opposed to http within the url of the post requests. The user authenticating against the endpoint must be allowed on the Sender access list.

Configuration

  1. Open the Canary Admin and select the Sender tile. Navigate to the 'Configuration' tab at the bottom of the screen, then select the 'Endpoints' tab on the left. Ensure that the 'Http - Anonymous (Web API)' endpoint is enabled.
  2. Select the 'Access' tab on the left and ensure the 'ANONYMOUS LOGON' user is listed in the 'ALLOW' menu. If it is not listed, click the 'ADD...' button to add it to the list.
  3. Open the Postman app and select 'Collections' within the 'Workspaces' page.  
  4. 'Import' the attached Canary_SenderWebAPI.postman_collection.json and Canary_SenderWebAPI.postman_environment files. 
  5. Select the 'Canary Instance' environment from the drop-down list.  
  6. Environment variables can be edited, if needed, by selecting the "eye" icon next to the drop-down list. The environment is configured to use the Sender service on the 'localhost'.
  7. To test the connection, select the 'getUserToken' from the Collections list. Select the 'Body' tab to see the JSON message that will be passed in.
  8. Press 'Send'. The call should return a 'Good' status with a userToken string value. 
  9. Select the 'getSessionToken' function from the list. A sessionToken is always needed when writing data to the historian and includes an array of 'settings'. A full list and description of these Session Settings can be found at writeapi.canarylabs.com.
  10. Press 'Send'. The call should return a 'Good' status with a sessionToken string value.
  11. Once a userToken and sessionToken are acquired, they can be passed into functions, such as 'storeData', for writing values into the historian.In this particular example, we are writing a value for tag1 and tag2 into the PostmanTest dataset. The dataset will be created automatically as the 'autoCreateDatasets' setting is set to 'true' in Step 9 when the sessionToken was generated.

Reply

null