Error 401 When Using SystemLink HTTP API in a Web App

Updated Aug 9, 2024

Reported In

Software

  • SystemLink Server
  • LabVIEW
  • G Web Development Software

Issue Details

  • I am creating a web VI in G Web Development Software. Whenever I try to use the SystemLink HTTP API, I receive status code 401. What causes this?
  • Whenever I make a HTTP request to my SystemLink Server from a VI, the HTTP response body is the HTML of the webpage. Why isn't the request working properly?
Status 401.PNG
 

Solution

This error occurs because of one or both of the below reasons:
  1. The HTTP request does not include the x-ni-api-key header.
  2. There is not an existing valid API key.
SystemLink uses API keys to automate access to the SystemLink API from an external application like a web VI. To resolve this issue, you must:
  1. Create a Policy. This defines an action, resource and workspace for a specific user.
  2. Create an API Key based on the Policy.
  3. Add the x-ni-api-key header with the new API key as the value to your web VI making HTTP requests.
Refer to Using API Key in SystemLink HTTP API for instructions.