Skip to main content
1-Visitor
March 29, 2016
Question

Problem in adding rows into infotable.

  • March 29, 2016
  • 12 replies
  • 7198 views

Hello all,

I am fetching data through REST API and trying to display that data in grid. REST transaction is successful and I could get the data.

But, when I try to push the data into infotable, it is not successful.

Testing the service will show only columns, doesn't show any rows. Below is the source code of the service.

Any help is appreciated in this.

With B/R,

Praveen.B

var restParams = {

  proxyScheme: undefined /* STRING */,

  headers: undefined /* JSON */,

  ignoreSSLErrors: undefined /* BOOLEAN */,

  useNTLM: undefined /* BOOLEAN */,

  workstation: undefined /* STRING */,

  useProxy: undefined /* BOOLEAN */,

  withCookies: undefined /* BOOLEAN */,

  proxyHost: undefined /* STRING */,

  url: "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url='http://rss.people.com/web/people/rss/topheadlines/index.xml'%20limit%203&format=json" /* STRING */,

  content: undefined /* JSON */,

  timeout: undefined /* NUMBER */,

  proxyPort: undefined /* INTEGER */,

  password: undefined /* STRING */,

  domain: undefined /* STRING */,

  username: undefined /* STRING */

};

// result: JSON

var jsonResult = Resources["ContentLoaderFunctions"].PostJSON(restParams);

var myItems= jsonResult["query"].results.item;

var Infoparams = {

  infoTableName : "InfoTable",

  dataShapeName : "RestExample"

};

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(RestExample)

var MyInfoTable = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(Infoparams);

function ProcessElements(element, index, array)

{

    var row = new Object();

    row.author = element.author;

    row.category = element.category;

  

    MyInfoTable.AddRow(row);

}

myItems.forEach( ProcessElements);

var result = MyInfoTable

12 replies

1-Visitor
March 29, 2016

"Testing the service will show only columns, doesn't show any rows." 

I tested your code and I can see two rows with data  authors -"Nick Maslow, @nickmaslow", "03/29/2016 10:00AM" and categories - "Music News, Britney Spears", "Movie News, Christian Bale" respectively. 

preddy-21-VisitorAuthor
1-Visitor
March 30, 2016

Hi Gautham,

Thanks for your response.

It is strange that, it is not working for me. I am using cloud instance of ThingWorx 6. Which version you are using?

I am just getting columns with no rows added to it.Am I missing something?

With B/R,

Praveen.B

1-Visitor
March 30, 2016

Hello Praveen,

I am also using ThingWorx 6. All I did is, Copied your code to a new service and created a data shape "RestExample" with fields "author" , "category"(base type - String). This is the result I got.

Untitled.png

preddy-21-VisitorAuthor
1-Visitor
March 30, 2016

Thanks for your response gautham.

I am still facing this issue. Can anyone has any guess what could be the issue?

With B/R,

Praveen

1-Visitor
March 30, 2016

Hi

Working for me too from the UK. Does the URL return data if you just put it in a browser?

In the browser, I found it easier to read the raw data by changing it to XML format - http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url=%27http://rss.people.com/web/people/rss…

Note that not all entries have category and author - you might be being unlucky and pulling back three results with blanks for both. I've just increased the limit to 10 on my instance and only 4 have authors and 6 have categories....

Regards

Ian

preddy-21-VisitorAuthor
1-Visitor
March 30, 2016

Hi lan,

URL returns proper data in browser. If I return these two fields as a String from service, it works.

If I create infotable with those data, it returns empty.

With B/R,

Praveen