Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

m.global from remote url json response

Hello, I need set the serverurl value from a json response of external url.

My MainScene.brs had this code:

m.global.addFields({serverurl: "https://host/endpoint", row: "", items: "", info: "", play: "", user: "", pass: "", expire: ""})

 

I tried to add this:

request = CreateObject("roUrlTransfer")
request.SetUrl("http://host/info.json")
html = request.GetToString()
data = html.Trim()
json = ParseJSON(data)
host = json.host.toStr()
name = json.name.toStr()

m.global.addFields({serverurl: host, row: "", items: "", info: "", play: "", user: "", pass: "", expire: ""})

I'm getting this error:

BRIGHTSCRIPT: ERROR: roUrlTransfer: creating MAIN|TASK-only component failed on RENDER thread: pkg:/components/MainScene.brs(11)

I tryied to add that code to main.brs and get this:

 

Interface not a member of BrightScript Component (runtime error &hf3) in pkg:/source/main.brs(16)
Backtrace:
#0 Function main() As Void
file/line: pkg:/source/main.brs(16

What is the correct or propper way to set global variable from url request?

0 Kudos
Community is Temporarily in Read-Only Mode!

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!