<?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[HttpBuilder.request()]]></title><description><![CDATA[<p dir="auto">Hi all,</p>
<p dir="auto">This is my first attempt to make a REST call to retrieve a point values array via Mango scripting  source.</p>
<p dir="auto"><strong>Via Swagger:</strong><br />
<em><strong>url:</strong></em><br />
<a href="http://localhost:8080/rest/v2/point-values/multiple-arrays/latest/DP_422050,CDP_614346?limit=3&amp;useCache=NONE" rel="nofollow ugc">http://localhost:8080/rest/v2/point-values/multiple-arrays/latest/DP_422050,CDP_614346?limit=3&amp;useCache=NONE</a></p>
<p dir="auto"><em><strong>result:</strong></em></p>
<pre><code>{
  "DP_422050": [
    {
      "timestamp": 1567738483443,
      "value": 175.51602162739323
    },
    {
      "timestamp": 1567738423443,
      "value": 175.16915149128016
    },
    {
      "timestamp": 1567738363443,
      "value": 174.31921651479684
    }
  ],
  "DP_614346": [
    {
      "timestamp": 1567738483443,
      "value": 211795
    },
    {
      "timestamp": 1567738423443,
      "value": 211790
    },
    {
      "timestamp": 1567738363443,
      "value": 211785
    }
  ]
}
</code></pre>
<p dir="auto"><strong>Via Mango scripting data source:</strong></p>
<pre><code>print(HttpBuilder.request({
    path: "http://localhost:8080/rest/v2/point-values/multiple-arrays/latest/DP_422050,DP_614346",
    method: "GET",
    headers : {
     "Cookie": "XSRF-TOKEN=6ac16488-db6d-4e64-8353-2faea1433e0f",
     "X-XSRF-TOKEN": "6ac16488-db6d-4e64-8353-2faea1433e0f",
     "Content-Type":"application/json;charset=UTF-8",
     "Host": "localhost:8080",
     "Accept": "application/json, text/plain"
     
  },
    parameters: {
    "limit" : 3,
    "useCache" : "None",
 },
    //content: "GETs don't have content!",
    err: function(status, headers, content) { //errorCallback for linguistic completion
        throw "Request got bad response: " + status;
    },
    resp: function(status, headers, content) { //responseCallback
        //try to retrieve the HttpBuilder object but no success
        //var result = JSON.parse(headers);
        //print(result);
        
        print(content);
        return true; //will print in wrapping print()
    },
    excp: function(exception) { //exceptionCallback
        throw exception.getMessage();
    }
}));

</code></pre>
<p dir="auto"><em><strong>result:</strong></em><br />
null</p>
<p dir="auto">I also tried to retrieve  the headers for a check test but no success. After some thought, I realize this might due to the "GETs don't have content". If this is the situation, how then can I access the point values array from return HttpBuilder object?</p>
<p dir="auto">Likelihood I am unable to grasp the concept of HttpBuilder correctly  and hopefully someone can help me out on the silly mistake I may have overlooked.</p>
<p dir="auto">Thanks and Best Regards</p>
]]></description><link>https://forum.mango-os.com/topic/4448/httpbuilder-request</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Mar 2026 08:24:05 GMT</lastBuildDate><atom:link href="https://forum.mango-os.com/topic/4448.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 06 Sep 2019 03:40:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to HttpBuilder.request() on Mon, 09 Sep 2019 02:06:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/phildunlap">@<bdi>phildunlap</bdi></a><br />
Thank you for your prompt reply. It works like a breeze.</p>
<p dir="auto">In my opinion, this is a powerful tool that open up the doors to communicate with internet of things / web content. In addition it provide flexibility to integrate your creativity into application.</p>
<p dir="auto">"Logic will get you from A to B. Imagination will take you everywhere".</p>
]]></description><link>https://forum.mango-os.com/post/23544</link><guid isPermaLink="true">https://forum.mango-os.com/post/23544</guid><dc:creator><![CDATA[Desmond]]></dc:creator><pubDate>Mon, 09 Sep 2019 02:06:42 GMT</pubDate></item><item><title><![CDATA[Reply to HttpBuilder.request() on Fri, 06 Sep 2019 14:05:05 GMT]]></title><description><![CDATA[<p dir="auto">Hi Desmond,</p>
<p dir="auto">It seems the first issue is a class cast exception for the <code>excp</code> function. You can remove this function and the <code>err</code> function will be used instead with status code -1. Thanks for bringing this to our attention! <a href="https://github.com/infiniteautomation/ma-core-public/issues/1489" rel="nofollow ugc">https://github.com/infiniteautomation/ma-core-public/issues/1489</a></p>
<p dir="auto">After that, I also had to modify the <code>"useCache": "None"</code> to be <code>"useCache": "NONE"</code> (other options  are <code>CACHE_ONLY</code> and <code>BOTH</code> )and I used an authorization token in my testing. This worked for me:</p>
<pre><code>var token = "token value from users page"

print(HttpBuilder.request({
    path: "http://localhost:8080/rest/v2/point-values/multiple-arrays/latest/DP_755013cd-03e3-4e9b-aad1-7a4575e58ebd",
    method: "GET",
    headers : {
     "Authorization":"Bearer "+token,
     "Content-Type":"application/json;charset=UTF-8",
     "Host": "localhost:8080",
     "Accept": "application/json, text/plain"
     
  },
    parameters: {
    "limit" : 3,
    "useCache" : "NONE"
 },
    //content: "GETs don't have content!",
    err: function(status, headers, content) { //errorCallback for linguistic completion
        throw "Request got bad response: " + status + " " +content;
    },
    resp: function(status, headers, content) { //responseCallback
        //try to retrieve the HttpBuilder object but no success
        //var result = JSON.parse(headers);
        //print(result);
        
        print(content);
        return true; //will print in wrapping print()
    }
}));
</code></pre>
]]></description><link>https://forum.mango-os.com/post/23524</link><guid isPermaLink="true">https://forum.mango-os.com/post/23524</guid><dc:creator><![CDATA[phildunlap]]></dc:creator><pubDate>Fri, 06 Sep 2019 14:05:05 GMT</pubDate></item></channel></rss>