Skip to main content
15-Moonstone
September 10, 2019
Question

How to get all alerts in JSON format using REST API from InfoTable

  • September 10, 2019
  • 6 replies
  • 2923 views

Hello,

I created custom service to fetch InfoTable data through Rest API and tried converting the output of the INFOTABLE using INFOTABLE.toJSON() function and set the output parameter accordingly but while I am trying to access it using rest API I am not getting the output in the JSON format.829D10B7.PNG

var params = {
	maxItems: undefined /* NUMBER */,
	onlyUnacknowledged: undefined /* BOOLEAN */,
	onlyAcknowledged: undefined /* BOOLEAN */
};

// result: INFOTABLE dataShape: "AlertSummary"
var data = me.GetAlertSummary(params);

var params = {
	table: data /* INFOTABLE */
};

// result: JSON
var result = Resources["InfoTableFunctions"].ToJSON(params); 

6 replies

22-Sapphire I
September 10, 2019

I believe for this to work you would need the datashape definition to also be part of that infotable.

I forget what other methods are available, I think you might be able to use Stringify

15-Moonstone
September 11, 2019

Hello @PaiChug, I tried attaching the data shape and then using stringfy() method on it however the result which I am getting is of the form whose image is attached below where it says BaseType = String and could not get the data which is stored in the infotable.I tried executing the service using REST API from Browser as well as Postman.

22-Sapphire I
September 11, 2019

With the DataShape defined, the ToJSON should work I believe, but I guess that wasn't the case either?