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
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.