<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Calling curl from inside script library?]]></title><description><![CDATA[<p dir="auto">I'm trying to build a series of scripts that send curl requests via command line to an external API. I've gone through the Docs multiple times but I haven't been able to find any documentation on how to use NSXL to send a curl command. I was able to get it to work under Actions Configuration, but I need this to occur during Hook::AlarmStateChange. </p>
<p dir="auto">For Curl to work via Actions I had to specify C:\\Windows\\System32\\curl.exe</p>
<p dir="auto">Is it possible to call this using NSXL?<br />
If it is not possible, should we be calling the server action instead?</p>
]]></description><link>https://forum.netxms.org/topic/7669/calling-curl-from-inside-script-library</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Nov 2026 10:35:47 GMT</lastBuildDate><atom:link href="https://forum.netxms.org/topic/7669.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 26 Apr 2023 21:08:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Calling curl from inside script library? on Tue, 02 May 2023 15:59:24 GMT]]></title><description><![CDATA[<p dir="auto">Yes, URL field supports macros, so <strong>%[OGAckAlarmID]</strong> should work. I am not sure how you are getting alarm ID in that script, may be you should pass the ID as parameter in your PostEvent() calls.</p>
<p dir="auto">Request Data field is employed when web service is used as data source for a DCI. When using post() method of web service object, that field is ignored, so you have to pass the whole request in post() call.</p>
]]></description><link>https://forum.netxms.org/post/32424</link><guid isPermaLink="true">https://forum.netxms.org/post/32424</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Tue, 02 May 2023 15:59:24 GMT</pubDate></item><item><title><![CDATA[Reply to Calling curl from inside script library? on Thu, 27 Apr 2023 21:01:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi Filipp,</p>
<p dir="auto">Thank you for your help! I was able to call postevent() during the hook using the following:</p>
<pre><code>sub main()
{
    eventserver = FindNodeObject($node, 100);
    global alarmstate = $alarm-&gt;state;
    switch(alarmstate)
    {
/* Alarm State is Outstanding */
        case "0":
            break;
/* Alarm State is Acknowledged */
        case "1":
            PostEvent(eventserver, "Xms_Alarm_Ack");
            break;
/* Alarm State is Resolved */
        case "2":
            PostEvent(eventserver, "Xms_Alarm_Resolve");
            break;
/* Alarm State is Sticky Acknowledged */
        case "17":
            PostEvent(eventserver, "Xms_Alarm_StickyAck");
            break;
    }
}
</code></pre>
<p dir="auto">I then created the following webservice with the following parameters:</p>
<p dir="auto"><strong>URL:</strong> <a href="https://api.opsgenie.com/v2/alerts/**%25%5BOGAckAlarmID%5D**/acknowledge?identifierType=alias" rel="nofollow ugc">https://api.opsgenie.com/v2/alerts/**%[OGAckAlarmID]**/acknowledge?identifierType=alias</a><br />
<strong>HTTP request method:</strong> POST<br />
<strong>Request data:</strong></p>
<pre><code>[
	{
		"user": "netXMS Admin",
		"source\\": "netXMS",
		"note": "Acknowledged via Alert API from netXMS - Time: %t"
	}
]
</code></pre>
<p dir="auto">I added the Authentication and the Content-Type:application/json in the Headers.</p>
<p dir="auto">Now the problem I am running into- The EPP script does not want to run the Webservice without the data argument being passed. I tried to use a variety of Macro schemes to pull the data from the webservice configuration data field but I keep coming up empty. using trace() provided no information either.</p>
<p dir="auto"><strong>Here are my questions:</strong></p>
<ul>
<li>Can I call a script inside the url field of the webservice configuration?</li>
<li>How do I reference the "<em>Request Data"</em> field in the webservice configuration when calling the post function?</li>
</ul>
<p dir="auto">I am attempting to call the post() function found here: <a href="https://www.netxms.org/documentation/nxsl-latest/#class-webservice" rel="nofollow ugc">https://www.netxms.org/documentation/nxsl-latest/#class-webservice</a></p>
]]></description><link>https://forum.netxms.org/post/32408</link><guid isPermaLink="true">https://forum.netxms.org/post/32408</guid><dc:creator><![CDATA[graeChris]]></dc:creator><pubDate>Thu, 27 Apr 2023 21:01:00 GMT</pubDate></item><item><title><![CDATA[Reply to Calling curl from inside script library? on Thu, 27 Apr 2023 15:36:13 GMT]]></title><description><![CDATA[<p dir="auto">First of all, there is built-in support for web services in NetXMS. It's possible to set up DCIs that get data from web services, but there's also ability to use them from NXSL scripts <a href="https://www.netxms.org/documentation/nxsl-latest/#class-webservice" rel="nofollow ugc">https://www.netxms.org/documentation/nxsl-latest/#class-webservice</a></p>
<p dir="auto">It's probably not a good idea to have long operations in hook scrips, so I would call PostEvent() from NXSL and then have a rule in EPP that catches that event and calls server action which calls NXSL script.</p>
]]></description><link>https://forum.netxms.org/post/32405</link><guid isPermaLink="true">https://forum.netxms.org/post/32405</guid><dc:creator><![CDATA[Filipp Sudanov]]></dc:creator><pubDate>Thu, 27 Apr 2023 15:36:13 GMT</pubDate></item></channel></rss>