Question on using POST /launch/

I am trying to send the roku a POST /launch ECP command to launch a particular channel, but keep getting back a “HTTP/1.1 400 Bad Request” response. Say I wanted to launch the Netflix channel. Its my understanding that I simply plug the proper app id (as returned by query/apps) in to the launch command. For example, with Netflix (app id = 12) I send the command:

POST /launch/12 HTTP/1.1 (with the appropriate cr lf following)

For a basic launch of this channel there really aren’t any parameters to also put in. Or are there? Am I missing something? I get similar failed responses when trying to launch, say, Vimeo or others.

Sounds like you are on the right track. The launch command does not require any parameters. I can successfully launch the Netflix channel using this command from a terminal and substituting the IP address of a Roku:

curl -d "" "http://xxx.xxx.xxx.xxx:8060/launch/12"

That syntax works fine for me. Are you specifying the HOST header with the appropriate 8060 port?

Thanks for the responses.

I’m doing a send to the same address/port (port being 8060) that I use for, say, a GET /query/apps or a POST /keypress (which work). The exact data I send is as in my first post, namely (for netflix):

“POST /launch/12 HTTP/1.1” (without the quotes and with two appended carriage return line feeds)

TheEndless, are you saying I need to literally include (append) a “Host: xxx.xxx.xxx.xxx:8060” on to the post data sent?

Yes, the HTTP protocol requires a Host header. You probably also need a Content-Length:0 header.

–Mark

Ah, so I assume that this is because HTTP 1.1 is being used as opposed to 1.0? But why then is it that if I do a POST for something like the KEYPRESS I have no problem withno header supplied?

Note: In the SDK example program to launch an app they provide no host header, but they use HTTP 1.0.

Here’s an example to launch netflix… insert your ipaddress in the line below:

echo -e “POST /launch/12 HTTP/1.1\r\n\r\n” | ncat 192.168.1.120 8060

–Kevin

RokuKevin,

That may work with ncat, but when (just) the line POST /launch/12 HTTP/1.1\r\n\r\n is sent programatically I get the “400 Bad Request” mentioned initially. I have not try it yet, but it may well be as TheEndless has suggested. With HTTP 1.1 (vs 1.0) the addtional header(s) are needed, at least the HOST: . I will try it and see. If it works then it will be puzzling why something like the POST keypress works without the header. That might mean there is something improper in the ROKU firmware.

I’ll post what I find…

Sorry for the confusion – it appears that no headers are necessary with either the keypress or launch commands.
The string you are sending should work fine. Make sure you don’t have any extraneous characters queued up in the socket (like from a previous command) before you send your command. That could cause the 400 error you’re seeing.

–Mark

Well for what it is worth…

When I had been trying to issue a POST launch (HTTP 1.1, not 1.0) without any headers I had no success. I confirmed (I swear) the content of the command text was fine. However, when I now add an additional Host: header (ie. Host: xxxx.xxxx.xxxx.xxxx:8060) the command(s) work and the channels launch. Makes sense, since the HTTP 1.1 spec does say the header (at least the host) is required.

My thanks to TheEndless for putting me on the right track!

Hm, well it works for me without headers. I do “telnet 192.168.1.xxx 8060” and then enter “POST /launch/12 HTTP/1.1” followed by two newlines, and I get a 200 OK response. But there’s certainly no harm in adhering to the spec by sending the Host header.

–Mark

Paps,

what app are using for the POST? (hyperterminal, c, c#, C++ java etc etc etc, mac, pc, linux etc etc)

tdurrant420,

I’ve been using both VB and even AutoIt, from/on a PC (XP and Vista). I should note that I also compiled and ran the sample SDK program related to ECP (it uses HTTP 1.0). One thing I noticed with it was that where it does a get/apps the response contains no apps. It gets the header part of the repsonse message back fine, and shows an appropriate number of bytes that should be in the message body. But there is no message body (ie. there’s the header , but no data).

A strange thing is that I had not been using the additional header in POSTs (or GETs). Keypress seemed to work without it. Get/apps had random problems, sometimes there’d be a usable response - sometimes not. But when I got to trying to launch apps nothing worked until I added the additional HOST: header. Now I’ve gone back and added the header to eveything I do (except the SSDP Discovery of course). That’s seems to have produced reliable exchanges.

The Roku shouldn’t be requiring the Host header, but maybe your client libraries do??

The sample app should not be requiring the header either. We tested it on Linux and Windows.

–Kevin

For my Philips pronto 9400 remote here is the script that I use. I have a page on my remote that shows my “favorites”, In each button I call the function:

roku_launch(11); //where the value is the id of the channel.

In the activities page I store the actual function :

function roku_launch(channel) {
//System.print(channel);
var url = CF.widget(“aURL”,“PARAMETERS”).label;
var timeout = CF.widget(“aTIMEOUT”,“PARAMETERS”).label;
var socket = new TCPSocket(true);
socket.connect(url, 8060, timeout);
socket.write(“POST /launch/”+channel+ " HTTP/1.1\r\n\r\n");
socket.close();
}

This works great.

Bill