Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
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.
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);
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
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.
With the DataShape defined, the ToJSON should work I believe, but I guess that wasn't the case either?
Your output type of the Service is JSON right?
You may also need to set the "Accept" header to let the server know what kind of response your HTTP request needs. You can set the Accept and Content-Type headers (the format of any data you are sending) in Postman
The different Accept headers that ThingWorx can handle are shown in the guide linked below. Not all of the Accept types are available for every REST call:
Because you are sending back a more complicated data structure, the Accept header may just set the "wrapper" around the data you are trying to read and not the actual data itself.
Hello,
In Thingworx,when I executed service I get result in table format ("JSON / String / Infotable") with header as per datashape but when I called same service through RestAPI method or Postman then result will be in single word "JSON / String / Infotable" as per service output.I want result in form of table like Thingworx. I attached Postman service for your reference.
The problem which I am facing is I am unable to view the contents of the INFOTABLE even after I set the accept and content type parameters along in the postman.