Search code examples
rokubrightscript

Web API Response For a Roku


I Simply Create a Web API in ASP.NET and API call in ROKU using "roUrlTransfer". Here blow my while Condition my Response Required For around 1 minutes. But here wait for only 20 seconds. Its Possible to wait 1 minutes For Response in ROKU.

First I Create a Response Like Below. readdata = CreateObject("roUrlTransfer") and set url here readdata.setUrl(data)

while(true)
   msg = Wait(0, m.port) ' here only 30000 millisecond pause
'  statusCode = msg.GetResponseCode()   ' check status code is working or not           
   if (type(msg) = "roUrlEvent")
      ?"event display here"
      statusCode = msg.GetResponseCode()
      headers = msg.GetResponseHeaders()
      if msg.getresponsecode() = 200 then
         data = msg.getstring()
         headers = msg.getresponseheadersarray()
         print "***************HEADERS******************"
         for each header in headers
             print header
         end for
         print "***************DATA*********************"
         print data
         print "****************************************"
         ?"statusCode value here : " statusCode
         exit while
       else
          readInternet.asynccancel()
          ?"here not valid username and password"
       end if
    else
       ? "do somthing useful while we wait for data"
    end if
end while

Solution

  • Pls, statusCode = msg.GetResponseCode() print in console if found "200" then completely getting response. Someone will put to a breakpoint in the web server and try to hold a response. But It's not possible in Roku Side. you can only manage around a 20-sec response in Roku. Pls, try to reduce response time in your server.