Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

How to call RestApi

Level 7

How to call RestApi


I am using below code for creating service to call RestAPI in thingworx ,

while executing service it is not giving any error but at the same time it is not giving output also,

please suggest what am i missing


below is the code:

var params = {
url: "http://localhost:8080/greeting/"

// result: JSON
var json = Resources["ContentLoaderFunctions"].GetText(params);

var obj = JSON.parse(json);
//var obj = JSON.parse('[{"id":69,"content":"Hello, World!"}, {"id":70,"content":"Hello, Bhau!"}]');

var paramsDS = {
infoTableName : "InfoTable",
dataShapeName : "RES_DS"

var infoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(paramsDS);

//for (var elem in json)
for (var i=0; i<obj.length; i++)
var row = obj[i];
//var userIdVal =;
var idVal =;
// var contentVal = row.content;
// var titleVal = row.title;
// var bodyVal = row.body;
// infoTable.AddRow({ id:idVal, content:contentVal});

var result = infoTable;




Re: How to call RestApi

Hi @Harsha11.


Apologies for the delay in responding to your post.


Have you defined the basetype for the output?  If you have already resolved this issue, please post your solution here for the benefit of others with similar issues.