Error 363650 When Using API Key in WebVI to Connect to SystemLink Server

Updated Oct 3, 2023

Reported In

Software

  • G Web Development Software
  • SystemLink Server

Issue Details

I'm trying to connect with a SystemLink Server from a WebVI, created in G Web Development System using an API key, running in a browser, but I'm getting this error:

image.png

HttpClientGet in NI::HTTP::httpWebServerClient.sli::httpWebServer_Get->NI::HTTP::GET.gvi->NI::Skyline::Utilities::Execute HTTP Verb.gvi->NI::Skyline::TagHTTP::Open Existing Tag.gvi->NI::Skyline::TagHTTP::Open Tag.gvi->WebApp::index.gviweb<APPEND>
A network error has occurred. Possible reasons for this error include Cross-Origin Resource Sharing (CORS) configuration issues between the client and the target server or that the client cannot reach the target server. Due to browser security restrictions, detailed information about the cause of the network error cannot be provided. You may find specific details about the cause of the network error in the browser development tools console or in the LabVIEW output window

Solution

The error is reported as the NI Web Server the SystemLink Server uses doesn't whitelist the X-NI-API-Key header as approved for Cross-Origin Resource Sharing (CORS).

The recommended way for a browser application to authenticate with SystemLink is to have the user log into the SystemLink web UI and then use the user's login session. This is what happens when using the Open Configuration (HTTP Auto) function instead of wiring explicit credentials.

Deploying the G Web webVI to the same NI Web Server as the SystemLink Server would both avoid CORS issues and enable the use of the auto configuration so that you don't need any credentials hard-coded in the webVI.