I tried to API call using below logic inside a Task node.
I test using the Postman tool My File Response takes around 800ms. I applied different below logic and the Results inside a Task node For fetch response from API.
'First Logic
url = "http://MyAPIHost:port/API.json" rxfer.SetUrl(url) m.raw = rxfer.GetToString()
json = ParseJSON(m.raw)
'When I performed the First logic. Results are below :
When the Application launch :
'Second Logic
url = "http://MyAPIHost:port/API.json" rxfer.SetUrl(url) m.port = CreateObject("roMessagePort") rxfer.SetPort(m.port) rxfer.AsyncGetToString() m.msg = wait(3000,m.port) if m.msg = invalid then rxfer.AsyncCancel() else m.raw = m.msg.GetString() ?"m.raw : "m.raw end if json = ParseJSON(m.raw)
'When I performed the Second logic. Results are below :
When the Application launch :
Third Logic(Using Internal File):
m.raw = ReadASCIIFile("pkg:/api/API.json") json = ParseJSON(m.raw)
'When I performed the Third logic. Results are below :
When the Application launch :
I don't understand one thing. It's giving a Execution timeout error. It's ok but why Roku Device restart's the Automatic. Does any one knows about this issue?
You are not creating a roUrlTransfer object.
url = "http://MyAPIHostSort/API.json"
rxfer = CreateObject("roUrlTransfer")
rxfer.SetUrl(url)
m.raw = rxfer.GetToString()
json = ParseJSON(m.raw)
print json
I have already created the roUrlTransfer object. I wrote code in short for better visibility.
We’re upgrading Roku Community to bring you a faster, more mobile-friendly experience. You may notice limited functionality or read-only access during this time. You will not be able to log in or post new comments or kudos during this time. Read more here.
Planned Downtime:
Community will be unavailable for up to 24–48 hours during the upgrade window during the week of May 12 and you may notice reduced functionality.
In the meantime, for additional assistance, visit our Support Site.
Thanks for your patience — we’re excited to share what’s next!