<?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[How can I make HTTP request with HttpBuilder in the new scripting environment?]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I need to make an HTTP post request in a Script Event Handler. But I keep getting errors when using HttpBuilder.</p>
<p dir="auto">At first I got the error: <strong>ReferenceError: HttpBuilder is not defined</strong></p>
<p dir="auto">Then I defined the HttpBuilder as :</p>
<pre><code>const HttpBuilder = Java.type('com.serotonin.m2m2.rt.script.HttpBuilderScriptUtility');
</code></pre>
<p dir="auto">Now I'm getting the error: <strong>TypeError: invokeMember (request) on com.serotonin.m2m2.rt.script.HttpBuilderScriptUtility failed due to: Unknown identifier: request</strong></p>
<p dir="auto">What am I missing here?</p>
]]></description><link>https://forum.mango-os.com/topic/5271/how-can-i-make-http-request-with-httpbuilder-in-the-new-scripting-environment</link><generator>RSS for Node</generator><lastBuildDate>Sun, 17 May 2026 00:26:50 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/5271.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 05 Aug 2021 13:25:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How can I make HTTP request with HttpBuilder in the new scripting environment? on Mon, 09 Aug 2021 05:05:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terrypacker" aria-label="Profile: terrypacker">@<bdi>terrypacker</bdi></a> thanks a lot, an example code is more than enough. I will look into the library in detail and see how to use it in the upcoming days.</p>
<p dir="auto">Thanks once again!</p>
]]></description><link>https://forum.mango-os.com/post/26926</link><guid isPermaLink="true">https://forum.mango-os.com/post/26926</guid><dc:creator><![CDATA[Mert]]></dc:creator><pubDate>Mon, 09 Aug 2021 05:05:05 GMT</pubDate></item><item><title><![CDATA[Reply to How can I make HTTP request with HttpBuilder in the new scripting environment? on Fri, 06 Aug 2021 12:33:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mert" aria-label="Profile: mert">@<bdi>mert</bdi></a> thanks.  I suggest you avoid the "Script Utility" classes when using the new javascript environment, they were specifically designed for the legacy engine and context and will probably be more confusing to use than directly using the underlying Apache http client library.</p>
<p dir="auto">I coded up an example using the library here:<br />
<a href="https://github.com/infiniteautomation/script-examples/blob/main/httpGetRequest.js" rel="nofollow ugc">https://github.com/infiniteautomation/script-examples/blob/main/httpGetRequest.js</a></p>
<p dir="auto">For reference I used this java code as my template to port into javascript:<br />
<a href="https://github.com/infiniteautomation/ma-modules-contrib/blob/main/system-settings-ds/src/com/infiniteautomation/mango/systemSettings/rt/SystemSettingsDataSourceRT.java" rel="nofollow ugc">https://github.com/infiniteautomation/ma-modules-contrib/blob/main/system-settings-ds/src/com/infiniteautomation/mango/systemSettings/rt/SystemSettingsDataSourceRT.java</a></p>
<p dir="auto">There is a lot more you can do with this client, my example is pretty basic but will give you a starting point.</p>
]]></description><link>https://forum.mango-os.com/post/26924</link><guid isPermaLink="true">https://forum.mango-os.com/post/26924</guid><dc:creator><![CDATA[terrypacker]]></dc:creator><pubDate>Fri, 06 Aug 2021 12:33:29 GMT</pubDate></item><item><title><![CDATA[Reply to How can I make HTTP request with HttpBuilder in the new scripting environment? on Fri, 06 Aug 2021 07:33:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/terrypacker" aria-label="Profile: terrypacker">@<bdi>terrypacker</bdi></a> I'm using Graal.js. Here is the script :</p>
<pre><code>const HttpBuilder = Java.type('com.serotonin.m2m2.rt.script.HttpBuilderScriptUtility');

HttpBuilder.request({
        path: url,
	method: "POST",
	headers: {
               ContentType : "application/json",
               Authorization : "Basic "+token,
	},
	content: JSON.stringify({
               "type": 0,
               "message": "This is a test message"
        }),
	err: function(status, headers, content) { //errorCallback
		throw "Request got bad response: " + status + content;
	},
	resp: function(status, headers, content) { //responseCallback
	        console.log(content)
    	        return true;
	},
	excp: function(exception) { //exceptionCallback
		throw exception.getMessage();
	}
});
</code></pre>
]]></description><link>https://forum.mango-os.com/post/26923</link><guid isPermaLink="true">https://forum.mango-os.com/post/26923</guid><dc:creator><![CDATA[Mert]]></dc:creator><pubDate>Fri, 06 Aug 2021 07:33:56 GMT</pubDate></item><item><title><![CDATA[Reply to How can I make HTTP request with HttpBuilder in the new scripting environment? on Thu, 05 Aug 2021 13:55:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mert" aria-label="Profile: mert">@<bdi>mert</bdi></a> I will need to see the entire script to help you out.  Also what script engine are you using Graal.js or Nashorn?</p>
]]></description><link>https://forum.mango-os.com/post/26921</link><guid isPermaLink="true">https://forum.mango-os.com/post/26921</guid><dc:creator><![CDATA[terrypacker]]></dc:creator><pubDate>Thu, 05 Aug 2021 13:55:51 GMT</pubDate></item></channel></rss>