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: 
Sembiance
Visitor

CreateObject roUrlTransfer returning Invalid

Hello

I have some fairly simple code:

testRequest = CreateObject("roUrlTransfer")
testRequest.SetUrl("http://blog.roku.com/developer")


The fails every time with this error:

BrightScript Debugger>
Current Function:
019: testRequest = CreateObject("roUrlTransfer")
020:* testRequest.SetUrl("http://blog.roku.com/developer")
021:
'Dot' Operator attempted with invalid BrightScript Component or interface reference. (runtime error &hec) in ...AAAAy0HwSV/pkg:/source/categories.brs(20)
020: testRequest.SetUrl("http://blog.roku.com/developer")
Backtrace:
#1 Function showcategories() As Void
file/line: ...AAAAy0HwSV/pkg:/source/categories.brs(20)
#0 Function init() As Void
file/line: ...AAAAy0HwSV/pkg:/source/categories.brs(9)
Local Variables:
global rotINTERFACE:ifGlobal
m roAssociativeArray refcnt=4 count:4
testrequest Invalid


Why is it always Invalid?
9 REPLIES 9
EnTerr
Roku Guru

Re: CreateObject roUrlTransfer returning Invalid

I for one am stumped. It shouldn't happen. Typically you'd get `invalid` from `createObject` if it failed to create what's requested. I thought maybe you created too many URLs - then i typed some code in console to create 10,000 roUrlTransfer but canceled it out of patience - still it created 3569 objects just fine:
BrightScript Debugger> a = [] : for ii=1 to 10000 : a.push(CreateObject("roUrlTransfer")) : next
^C
BREAK (runtime error &hf8) in $LIVECOMPILE(73)

BrightScript Debugger> ? ii, a.count()
3570 3569

BrightScript Debugger> ? a[3500]
<Component: roUrlTransfer>

BrightScript Debugger> a[3500].SetUrl("http://blog.roku.com/developer")

BrightScript Debugger> bscs
roArray: 14
roAssociativeArray: 106
roByteArray: 1
roGlobal: 1
roImageCanvas: 1
roInt: 2
roList: 8
roMessagePort: 8
roString: 187
roUrlEvent: 8
roUrlTransfer: 3579
Total # components: 3915

How does it act if you type in console your 2-line snippet, after the run was interrupted by the error?
0 Kudos
Sembiance
Visitor

Re: CreateObject roUrlTransfer returning Invalid

I think I may have found the cause.

This code was being called from within 'sub init()' in a a 'categories.brs' file that was included from a categories.xml file as such:

<script type="text/brightscript" uri="pkg:/source/categories.brs" />


If I take it out of this file and move it to the main.brs file that has 'sub Main()' it works just fine from there.

So I dunno if this is maybe a security thing not to allow creating url connections from code referenced from XML files or not.
EnTerr
Roku Guru

Re: CreateObject roUrlTransfer returning Invalid

Oh, that's the new XML carp? <nose wrinkle="on"/>
There is a beadroll of unsupported fn here http://sdkdocs.roku.com/display/sdkdoc/ ... pt+Support
No reason is given, my guess is thread-unsafe
0 Kudos
Sembiance
Visitor

Re: CreateObject roUrlTransfer returning Invalid

"EnTerr" wrote:
Oh, that's the new XML carp? <nose wrinkle="on"/>
There is a beadroll of unsupported fn here http://sdkdocs.roku.com/display/sdkdoc/ ... pt+Support
No reason is given, my guess is thread-unsafe


I figured it must be something like that.

I've already discovered the legacy regular roku interface code and have coded my channel in that. Works great!!! No XML nonsense either. Sure the resolution is a bit old-school, but it works 🙂

Thanks for the link though, I appreciate it 🙂
0 Kudos
TheEndless
Channel Surfer

Re: CreateObject roUrlTransfer returning Invalid

In SceneGraph, all web requests have to be made from a Task node. You cannot make web requests from the main UI thread, which is the context in which init() runs.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
0 Kudos
NicholasStokes
Binge Watcher

Re: CreateObject roUrlTransfer returning Invalid

Hello,
 
I am trying to integrate external API into my channel for that i have created new brs file and i got the below error.
 
filereadInternet = createObject(“roUrlTransfer”)
readInternet.setUrl("https://dummy.restapiexample.com/api/v1/employees")
htmlOp = readInternet.GetToString()
 
‘Dot’ Operator attempted with invalid BrightScript Component or interface reference at setUrl component.Please provide the correct process.
 
 
 
0 Kudos
renojim
Community Streaming Expert

Re: CreateObject roUrlTransfer returning Invalid

You have filereadInternet on one line and readInternet on the other.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
NicholasStokes
Binge Watcher

Re: CreateObject roUrlTransfer returning Invalid

Hello,

I am trying to integrate external API into my channel for that i have created new brs file and i got the below error.

request = createObject(“roUrlTransfer”)
request.setUrl("https://dummy.restapiexample.com/api/v1/employees")
html = request.GetToString()

‘Dot’ Operator attempted with invalid BrightScript Component or interface reference at setUrl component.Please provide the correct process.

0 Kudos
renojim
Community Streaming Expert

Re: CreateObject roUrlTransfer returning Invalid

@NicholasStokes, if you print "request" you'll probably see that it's invalid.  You can't use roUrlTransfer in the render thread I'm going to assume is what you're trying to do.  You have to set up a task or use it in the main thread.

Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos