Skip to main content
10-Marble
August 21, 2020
Solved

Populate a parameter value from Rest Server (Using Home.js)

  • August 21, 2020
  • 1 reply
  • 2044 views

Hi Experts,

 

Would be possible to populate a parameter value from a Rest Server coding a javascript on home.js?

I have a IoT Gateway on Kepware which reads values from controllers and publish those on a Rest Server, then I need to use those values on Vuforia Studio WHITHOUT ThingWorx.

This requirement is because I do not want to have (pay for) ThingWorx to act just as a gateway since I just need real-time values on Vuforia Studio.

I know ThingWorx is there with Vuforia, but in order to use it to collect this data on Things I would need to license it, right?

 

All ideas is welcome.

 

Many Thanks,

Felipe Duarte

Best answer by sdidier

Hello FbdSilva,

 

Yes in https, it should work.

I used this Javascript code in my test :

function GetDataREST () 
{
 console.log('GetDataREST');
 
 fetch('https://ghibliapi.herokuapp.com/films')
 .then(response => response.json())
 .then(json => {console.log(json); })
 .catch(error =>{ console.error(error);}) 

}

GetDataREST();

 

Best regards,

Samuel

1 reply

17-Peridot
August 28, 2020

Hello fbdsilva,

 

Please read this post from Roland :

https://community.ptc.com/t5/Vuforia-Studio/How-to-read-sensors-via-Rest-API-call-in-and-display-it-Vuforia/m-p/581091

 

Yes, it is possible but only for https.

When using http URL to fetch data, it is not working.

 

Best regards,

Samuel

fbdsilva10-MarbleAuthor
10-Marble
August 28, 2020

Hi Samuel,

 

Thanks for replying.

 

Yes, I have read that post before but there it is showing how to make that from ThingWorx. 

Just to be clear, if I used those javascript from the very beginning of the post with https it would work? Because I have tested a lot and could not make it work but I will try again if it is possible.

 

Thanks,

Felipe Duarte

sdidier17-PeridotAnswer
17-Peridot
August 31, 2020

Hello FbdSilva,

 

Yes in https, it should work.

I used this Javascript code in my test :

function GetDataREST () 
{
 console.log('GetDataREST');
 
 fetch('https://ghibliapi.herokuapp.com/films')
 .then(response => response.json())
 .then(json => {console.log(json); })
 .catch(error =>{ console.error(error);}) 

}

GetDataREST();

 

Best regards,

Samuel