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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Getting blank infotable after fetching data from URL using GetJSON(param) method

pmishra-4
1-Visitor

Getting blank infotable after fetching data from URL using GetJSON(param) method

Hi ,I am trying to pull data using method GetJSON. But i am getting blank infoTable. While i am getting result in postman fro the same URL. Below is the code snippet :-

var params1 = {

proxyScheme: undefined /* STRING */,

headers: {

  "Accept": "*/*",

  "tenantId": "12345"

}/* JSON */,

ignoreSSLErrors: undefined /* BOOLEAN */,

useNTLM: undefined /* BOOLEAN */,

workstation: undefined /* STRING */,

useProxy: undefined /* BOOLEAN */,

withCookies: undefined /* BOOLEAN */,

proxyHost: undefined /* STRING */,

//url:"http://dev1.tcupiot.com/app/user5/TTSLService/Alert/Query?eventDateTime=YYYY-MM-dd" /* STRING */,

url:"http://localhost:8081/TTSLFleetWeb/Alert/Query?eventDateTime=YYYY-MM-dd" /* STRING */,

    timeout: undefined /* NUMBER */,

proxyPort: undefined /* INTEGER */,

password: undefined /* STRING */,

username: undefined /* STRING */

};

// result: JSON

var data = Resources["ContentLoaderFunctions"].GetJSON(params1);

var params = {

infoTableName: "alertTable" /* STRING */,

dataShapeName: "AlertDataShape" /* DATASHAPENAME */

};

// result: INFOTABLE

var jsonTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

for(var i=0;i<data.length;i++)

{

jsonTable.AddRow({vehicleRegNo:data.array.vehicleRegNo,

                  eventTypeName:data.eventTypeName,

                  eventLocDescription:data.eventLocDescription,

                  eventDatetime:data.eventDatetime,

                  speed:data.speed,

                  description:data.description});

}

//}

result = jsonTable;

ACCEPTED SOLUTION

Accepted Solutions
posipova
20-Turquoise
(To:pmishra-4)

In your "for" function, you have to specify the array index in each, i.e i<data.rows.length and for each element name:data.rows.name

View solution in original post

3 REPLIES 3
posipova
20-Turquoise
(To:pmishra-4)

In your "for" function, you have to specify the array index in each, i.e i<data.rows.length and for each element name:data.rows.name

posipova
20-Turquoise
(To:posipova)

You may also look into using this extension ThingWorx IoT Marketplace

Thank you . It worked out.

Announcements


Top Tags