Tag Change Triggering Gateway Event Script

Good afternoon! I am just starting to get my feet wet with Ignition and need some help getting a tag change to trigger a post call to an API.
I am trying to use a tag change from an OPC server to drive a httpPost for a telemetry device. I have been able to get the gateway event to successfully trigger on a local installation of ignition using a demo OPC server but have not been able to replicate the same results with the Dev Server that my company has. I can see the values changing on the OPC side and have even tried to just attach the change action to the timestamp to try to get the event to trigger.
Here is an image of my gateway configuration script on the Dev Server.

The Script works both through the script console and through Postman, so I don't believe the issue is my script.

These calls originate from your PC, while the tag change event script is executing on whatever server the Ignition Gateway is running on. Does that server have access to the IP you're calling?

You should log or print the response so you know what's happening.

Also, do not create system.net.httpClient() instances for every event, as that leads to memory leaks.

Write your script as a function in a project library, and assign to client outside the function. (That makes it persistent for multiple calls.)

I was able to get logging enabled and it looks like I am getting a response, but the logs don't go into more detail what the response is. I also added a get function to try to elicit a more detailed response. Is there a way to get a better response from the postlogs?

I will add the client to outside the function.

Show us your logging code

client = system.net.httpClient()
response = client.post ('http://10.201.150.11/api/v0/inputs/1')
print(response)
logger = system.util.getLogger("postlogs")
logger.debug("response")
logger.info("response")

You're just logging the literal string "response".

2 Likes

You haven't put your code in a script library function. :man_shrugging:

The assignment to logger should also be outside the function, to make it persistent.