pradeeptv
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2013
11:05 PM
HTTP Post Not working
We are trying to implement the HTTP POST request on the ROKU but it is not working giving us the HTTP 405 error, but we are posting the data with the method PostFromString("").
Please Find the Code Snippet
Thanks In Advance.
Bhushan
Please Find the Code Snippet
timeout% = 1500
roRequest = CreateObject("roURLTransfer")
roRequest.setUrl("http://httpbin.org/post")
roPort = CreateObject("roMessagePort")
roRequest.setPort(roPort)
roRequest.PostFromString("Please Work ")
sleep(1000)
if (roRequest.AsyncGetToString())
roEvent = wait(timeout%, roRequest.GetPort())
print roEvent
if type(roEvent) = "roUrlEvent"
str = roEvent.GetString()
print "i am here"
print roEvent.GetResponseCode()
print str
else if roEvent = invalid
roRequest.AsyncCancel()
REM reset the connection on timeouts
print "Unknown"
else
print "roUrlTransfer::AsyncGetToString(): unknown event"
endif
endif
Thanks In Advance.
Bhushan
4 REPLIES 4

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2013
11:13 PM
Re: HTTP Post Not working
You're getting a 405 from the AsyncGetToString() call. Your PostFromString() call does the post, then discards the response (as documented here: http://sdkdocs.roku.com/display/RokuSDK ... ingrequest). I think you should remove the PostFromString() line and change the AsyncGetToString() with AsyncPostFromString("Please Work "), and you should get the result you're looking for.
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)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
pradeeptv
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2013
12:01 AM
Re: HTTP Post Not working
Hello,
We tried with the suggestion provided by you but we are getting the roEvent as invalid.
Please find the code snippet below
We tried with the suggestion provided by you but we are getting the roEvent as invalid.
Please find the code snippet below
timeout% = 1500
roRequest = CreateObject("roURLTransfer")
roRequest.setUrl("http://httpbin.org/post")
print "start from here"
roPort = CreateObject("roMessagePort")
roRequest.setPort(roPort)
print "after setting the port"
sleep(1000)
if (roRequest.AsyncPostFromString("Please Work"))
roEvent = wait(timeout%, roRequest.GetPort())
print roEvent
if type(roEvent) = "roUrlEvent"
str = roEvent.GetString()
print "i am here"
print roEvent.GetResponseCode()
print str
else if roEvent = invalid
roRequest.AsyncCancel()
REM reset the connection on timeouts
print "Unknown"
else
print "roUrlTransfer::AsyncGetToString(): unknown event"
endif
endif
renojim
Community Streaming Expert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-31-2013
01:03 AM
Re: HTTP Post Not working
Your code works for me. You might want to try a timeout of 0 (zero). You'll get an invalid event if the timeout occurs before the async transfer completes.
-JT
-JT
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.
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.
pradeeptv
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2013
03:04 AM
Re: HTTP Post Not working
Thanks! It's working