SystemLink Forum

Showing results for 
Search instead for 
Did you mean: 

Swagger Generated Python and local NI Web Server Access Problem

I'm trying to build up a skeletal design that has a G Web App, a LabView App and a Python-based App.  I am looking at the SystemLink OpenAPI github (systemlink-OpenAPI-documents/nimessage.yml at master · ni/systemlink-OpenAPI-documents · GitHub) and I am trying to get a publish/subscribe test working between a G Web App and a Python App.  I used swagger on nimessage.yaml and produced a Python client, which I'm trying to get working with a local NI Web Server on my local machine (no SystemLink cloud access).  I took the Getting Started example that swagger produced, and am working on that but it's failing with the following error:


2022-10-19 14:00:31,725 WARNING Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x0000028CB064DFD0>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it')': /nimessage/v1/sessions/token_example/messages


The NI Server is running.  Are there some examples elsewhere of using the SystemLink OpenAPI with another language like Python (preferrably accessing locally stored tags by the NI Web Server)?  I attached the Python code as swagger produced, and I only changed the username and password.  I'm trying to access a tag that's already created on the NI Web Server, and viewable at localhost/#tagviewer.  Is the approach that I'm taking, correct?  Is there something else that I need to do in order to get publish/subscribe working and tag sharing between a G Web App locally with the NI Web Server, and a Python program?  Thank you.

0 Kudos
Message 1 of 5

I haven't tried to generate and use clients made from the swagger APIs myself but one thing to be aware of is that systemlink offers a pre-made python client for the tags api here:


0 Kudos
Message 2 of 5

Milan, thanks for the link.  Will the nisystemlink-client Python code work with a locally hosted NI Web Service with the tag service running?

0 Kudos
Message 3 of 5

Yep! After installing the nisystemlink-clients python API, I would expect that a system with the NI Web Server and Tag APIs could run the Python examples on the same system as shown in the documentation.


If the Python API + Python application are on a different system writing to tags on the NI Web Server on a separate machine then you would need to follow the Getting Started: Overview to create an HttpConfiguration object pointing to the NI Web Server and make sure the NI Web Server Configuration allows remote HTTP connections.


Which would look a bit like adding the import:


from systemlink.clients.core import HttpConfiguration


And creating a HttpConfiguration to use:


cfg = HttpConfiguration("http://my_server_url", username="MY_USERNAME", password="MY_PASSWORD")
mgr = TagManager(cfg)


0 Kudos
Message 4 of 5

Hi Milan,


I put a support request in for the other thread we were exchanging messages on.  For this thread, I cloned the nisystemlink-clients-python git repo, and modified the one example  The code now looks like the following:


from datetime import timedelta
from systemlink.clients.tag import DataType, TagManager
from systemlink.clients.core import HttpConfiguration

httpCfg = HttpConfiguration(server_uri="http://localhost:9090", username="admin", password="test")
     mgr = TagManager(httpCfg)
except Exception as e:
     print("TagManager error raised is: ", e)
     tag ="NIConnect.temp", DataType.DOUBLE, create=True)
except Exception as e:
     print("TagManager open error raised is: ", e)

     with mgr.create_writer(buffer_size=10, max_buffer_time=timedelta(seconds=3)) as writer:
     writer.write(tag.path, tag.data_type, 3.5)
     # Note: Exiting the "with" block automatically calls writer.send_buffered_writes()

     read_result =
     assert read_result is not None
     assert read_result.value == 3.5
     print("Tag written successfully!")


I get the following error when I run this, and I left out the HTML that also gets displayed after the following (this should look familiar; it's the same problem as the other thread):


TagManager open error raised is: Server responded with <403 Forbidden> when calling GET (http://localhost:9090/nitag/v2/tags/NIConnect.temp😞


I can access this exact URL from my Edge browser and I see the following:




But there is no 403 error.  Something appears to be going on with the NI SystemLink client framework code.  Can you think of anything else I can try?


0 Kudos
Message 5 of 5