Facility Control

 View Only
  • 1.  Beginner asyncHTTP get questions.

    Posted 05-23-2022 15:36

    Hello, I'm a beginner with Dashboard, and have a question on HTTP GET queries.

    I can successfully receive a response from a device when I use Postman, but don't seem to receive the data in Dashboard.  Or I'm thinking I maybe need to create an object from the response before I can work with it?

    Here's a screen shot from Postman.


    In dashboard I've created a button and assigned a task to it, with the ogScript...

    ogscript.asyncHTTP("http://192.168.1.120:8060/query/device-info", "GET", "text/plain", "", rokuCallback);

    and then created a rokuCallback api...

    function rokuCallback(resultData)
    {
      if (resultData == null){
        ogscript.debug('No data');
      }else{
        ogscript.debug('Result is: ' + resultData);
      }
    }

    and I get 'No Data' in debug.  Any advice would be appreciated!



  • 2.  RE: Beginner asyncHTTP get questions.

    Posted 05-23-2022 18:22
    I looked at it in a different way and was able to gather the data I needed with this code, and just printing to debug for now.

    var rokuApps = ogscript.parseXML('http://192.168.1.120:8060/query/apps\n');
    var nodeList = ogscript.runXPath('apps/app', rokuApps);
    var appList = '<app>';
    
    ogscript.debug(nodeList.getLength());
    
    for (var i = 0; i < nodeList.getLength(); i++)
    {
       appList = appList + nodeList.item(i).getTextContent();
       ogscript.debug('app = ' + nodeList.item(i).getTextContent());
    }​


    ------------------------------
    Matt Rasmussen
    FinePoint Technology
    ------------------------------