The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.
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;
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