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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

How to call RestApi

Harsha11
6-Contributor

How to call RestApi

Hi,

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 = row.id;
var idVal = row.name;
// var contentVal = row.content;
// var titleVal = row.title;
// var bodyVal = row.body;
infoTable.AddRow({id:idVal});
// infoTable.AddRow({ id:idVal, content:contentVal});
}

var result = infoTable;

 

 

1 REPLY 1
slangley
23-Emerald II
(To:Harsha11)

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.

 

Regards.

 

--Sharon

Top Tags