Hi all,
This is my first attempt to make a REST call to retrieve a point values array via Mango scripting source.
Via Swagger:
url:
http://localhost:8080/rest/v2/point-values/multiple-arrays/latest/DP_422050,CDP_614346?limit=3&useCache=NONE
result:
{
"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
}
]
}
Via Mango scripting data source:
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();
}
}));
result:
null
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?
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.
Thanks and Best Regards