This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

Finding a SystemLink Workspace ID

Updated Oct 31, 2023

Environment

Software

  • SystemLink

This article demonstrates how to obtain the ID for a Workspace in SystemLink.
In some instances, it's necessary to provide a Workspace ID when getting and setting Tags. Some examples of HTTP API that require a Workspace ID as an input parameter are:
 
  • GET /v2​/tags-with-values​/{workspace}​/{path} - Returns a tag and its current value.
  • GET ​/v2​/tags​/{workspace}​/{path}​/values - Get the aggregates and current value of a tag.
  • PUT /v2​/tags​/{workspace}​/{path}​/values​/current - Update the current value of a tag.
  • PUT ​/v2​/tags​/{workspace}​/{path} - Create or replace a tag in the given workspace.
  • GET ​/v2​/tags​/{workspace}​/{path} - Get a tag from the given workspace.
  • DELETE ​/v2​/tags​/{workspace}​/{path} - Delete a tag from the given workspace.
  • POST ​/v2​/tags​/{workspace}​/{path}​/reset-aggregates - Reset the aggregates of a tag.

Follow the relevant sections below, depending on whether you're working with the Default Workspace or other Workspace.


Default Workspace

If using the Default Workspace, obtain the Workspace ID using the HTTP API on Swagger UI.
 
  1. From the SystemLink Web Interface, navigate to the Utilities >> Tags page.
  2. Click the question mark (?) in the top right-hand corner and select HTTP API. This will take you to the Swagger UI page.
    • Alternatively, enter <server URL>:<port>/niapis/ in the browser URL bar. Note: the server URL and port can be found in the NI Web Server Configuration application.
  3. On the Swagger UI, click the Select a definition drop-down menu and choose Tag Service.
  4. Scroll down until you reach the Tags section of the API list.
  5. Click on the GET /v2/tags/{path} API.
  6. Once expanded, click the Try it out button.
  7. Enter the Tag path of any Tag that resides in your Default Workspace.
    • This example retrieves the value of a Tag called test.
  8. Click Execute.
  9. In the Server response section, copy the value of the workspace property, highlighted below.
Get tag workspace ID.PNG


Non-Default Workspace

If the ID of a Workspace that was manually created (i.e. not Default) is required, use the SystemLink LabVIEW API.
The Swagger UI API automatically queries and retrieves values from the Default Workspace to maintain simplicity. More granular configuration can be set using the SystemLink LabVIEW API.
 
  1. If not already installed, download and install the SystemLink LabVIEW API here.
  2. On the SystemLink Web Interface, create a Tag that resides in the Workspace of interest.
    • Refer to Monitoring Data with Tags for instructions.
    • The image below represents a Tag called test2 inside a Workspace called Test.
    • Test tag.PNG
  3. Launch LabVIEW and click File >> New VI to open a new VI.
  4. Place a SystemLink Open Configuration VI from the Data Communication >> SystemLink >> Configuration Palette.
    • Ensure that the Polymorphic Selector is set to HTTP.
    • Create a Constant on the server url input and set it to the URL of your server.
      • Note: This can be found in the NI Web Server Configuration application.
      • The format should follow <hostname>.<domain>:<port>
    • Create a Constant on the username and password inputs and set them to the credentials of a user account that has access to your Workspace.
    • Place a Query Tags VI from the Data Communication >> SystemLink >> Tags Palette.
      • Connect the configuration output from Open Configuration to the configuration (system default) input of Query Tags.
      • Connect a False Constant to the limit to configured workspace? input.
      • Create a Constant on the paths input. Set the first element of the array to the name of the tag created in step 2.
        • For this example, the element is set to test2.
    • Place a For Loop after the Query Tags VI.
      • Connect the tags output of Query Tags to the For Loop, ensuring that the terminal is indexing.
    • From the Data Communication >> SystemLink >> Tags Palette, place a Tag Property Node inside the For Loop.
      • Set the active property to Workspace ID.
      • Connect the output of the Property Node to the end of the For Loop, ensuring that the terminal is indexing.
      • Create an Indicator on the Workspace IDs indexing terminal.
    • Place a Close Configuration VI after the For Loop.
      • Connect the configuration output from Open Configuration to the configuration input of Close Configuration.
    • When the finished VI runs, the Workspace IDs output array will contain the ID required.

Get Workspace ID Snippet.png
Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.