Your Digital Media Has Never Looked So Good

Topic Author
Posts: 1
Joined: Fri Sep 28, 2018 3:59 am

How do i recreate a html request header?

Fri Sep 28, 2018 4:27 am

I'm currently writing a Java Application that remotely controls my Roku. I found this website and used it to control my Roku. From Chromes developer tools i watched its data traffic and found the html request that controlled the Roku. The Header was this.

POST /keydown/Play HTTP/1.1
Connection: keep-alive
Content-Length: 0
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8
I then tried to recreate this POST request within Java and it ended up looking like this:

HttpURLConnection urlConn;
URL url = new URL("html://");
urlConn = (HttpURLConnection) url.openConnection();

urlConn.setRequestProperty("Connection", "keep-alive");
urlConn.setRequestProperty("Content-Length", "0");
urlConn.setRequestProperty("Cache-Control", "max-age=0");
urlConn.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
urlConn.setRequestProperty("Origin", "");
urlConn.setRequestProperty("Upgrade-Insecure-Requests", "1");
urlConn.setRequestProperty("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36");
urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
urlConn.setRequestProperty("Referer", "");
urlConn.setRequestProperty("Accept-Encoding", "gzip, deflate");
urlConn.setRequestProperty("Accept-Language", "en-US,en;q=0.8");
I'm not 100% sure this is the correct way to recreate the request because it does not have the same effect as the the original (working). However, this may be because I changed a few minor details that may have actually be important. So my question to you is if this the correct way to recreate a request and if it is why is it not working? If not what is? Any help is appreciated
User avatar
** Valued Community Member **
Posts: 5520
Joined: Sun Nov 30, 2008 4:51 pm
Location: Milwaukee, WI

Re: How do i recreate a html request header?

Fri Sep 28, 2018 5:25 am

I'd post this in the Developer's forum instead.
Yeah, I got some Rokus.
Posts: 1465
Joined: Thu Dec 09, 2010 1:43 pm

Re: How do i recreate a html request header?

Fri Sep 28, 2018 10:07 am

Most of those properties you're setting are unnecessary. The one thing you do need that you're missing is setRequestMethod("POST"). I don't do Java, so there may be other issues with your code.

Also, instead of using Chrome Developer Tools to determine the Roku interface, why not read the documentation:
Posts: 1
Joined: Tue Jan 15, 2019 11:18 pm

Re: How do i recreate a html request header?

Wed Jan 16, 2019 9:29 pm

I agree with belltown.
Java Developer
Posts: 2720
Joined: Sat Dec 18, 2010 4:58 pm

Re: How do i recreate a html request header?

Thu Jan 24, 2019 9:38 am

Roku also has a bunch of free tools here -
RemoteRoku is the first on the left, Deeplinker allows you to add fields in addition to contentID and Mediatype too.
I don't think their tools allow much interaction (if any) with customizing headers in requests there, but they shouldn't be needed except for perhaps the video playback tester tool, which includes a headers tab.
As for creating a header in the channel app, use AddHeader
Posts: 99
Joined: Thu Apr 13, 2017 11:00 pm

Re: How do i recreate a html request header?

Thu Apr 18, 2019 8:23 pm

If you set on using chromes developer tools, may I suggest right clicking on the data you are referring to and "copy as curl"

Who is online

Users browsing this forum: No registered users and 2 guests