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

roUrlTransfer Request Returns Nothing

I'm having problems receiving a response for one of my REST requests.
Basically, my app is able to parse responses from URLs like this:

But when I add more to the request:
    http://arkbroadcasting.com/rest/play_info.php?video=10&ads=0&prevFillers[]=2000

The debug console shows that I receive no response (not even an error message).

This is the code fragment in question:
' Form a standard request to the server
mediaLink = "http://arkbroadcasting.com/rest/play_info.php?video=" + calID + "&ads=" + adsID

' Include the last 10 filler video IDs in request
' Including this section of code causes requests to fail when the code is run:
'for i = 0 to fillerList.count() - 1
' mediaLink = mediaLink + "&prevFillers[]=" + fillerList[i]
'end for

' Send request to the server and decode response
mediaRequest = CreateObject("roUrlTransfer")
mediaRequest.SetURL(mediaLink)
data = ParseJson(mediaRequest.GetToString())

print "Video Request URL: " + mediaLink
print "Video Response: " + mediaRequest.getToString()


From my testing, it appears that there is a problem when I add &prevFillers[]=2000 (or the like) to the end of my request URL, but I'm not sure why, or how to resolve the problem. All other requests are served normally for me.
I think it has to do with having [ and ] in the request URL?

Thought I'd include the debug console fragment in question. The two print statements at the bottom of my fragment print these two lines in the first case:
Video Request URL: http://arkbroadcasting.com/rest/play_info.php?video=10&ads=0
Video Response: {"video":"0","filler":"1","filler_id":"7","filler_filename":"1357582161_GettingtoKnowBCF720p.mp4","ads":"0"}
And this in the second case:
Video Request URL: http://arkbroadcasting.com/rest/play_info.php?video=10&ads=0&prevFillers[]=2000
Video Response:
0 Kudos
2 REPLIES 2
RokuChris
Roku Employee
Roku Employee

Re: roUrlTransfer Request Returns Nothing

Be sure your URL is properly url-encoded before you call SetURL() on your roURLTransfer object, otherwise SetURL() will fail.

After setting the URL, I like to make a debug call to GetURL() to confirm that the URL actually got set.

xfer.SetURL("http://www.example.com")
? "DEBUG: " + xfer.GetURL()
0 Kudos
kratosauron0
Visitor

Re: roUrlTransfer Request Returns Nothing

I'm not sure how to use the URL encode functions. I found a function in the documentation:
http://sdkdocs.roku.com/display/RokuSDK ... eStringurl
But I couldn't get it to work properly

However, through further research, it seems my problem was that I need to use %5B to encode [ and %5D to encode ]. Changing the URL to use this URL encoding fixed my problem.
Therefore, the URL was changed to:
http://arkbroadcasting.com/rest/play_in ... rs%1B%1D=7
0 Kudos