Web interface problems with April update

#1

I don’t know if this is an OSMC issue or a general Kodi 18 problem that I should put in a Kodi forum somewhere. I’m running OSMC on a raspberry pie using a web interface of my own design. It works fine on previous versions of OSMC that does not work after the April update which of course includes update from 17- 18. I can still remote control device using an app on my iPhone. But the webpage interface that used to work doesn’t anymore. Any advice?

#2

Check in the settings that the port in use didn’t switch from 80 to 8080 or vice versa.

#3

The port is 80 and always has been.

#4

What you mean by that? Please, give more details.

#5

Could it be that Kodi 18’s JSON API requires JSON POSTs instead of GET requests?

1 Like
#6

There is a webpage on the raspberry pi that looks like the attached image. When you click on the buttons or price variance keyboard shortcuts it is used as a remote control on the OSMC. It does so using the JSON-API interface. For example if I click on the right arrow button it sends

http://192.168.1.115/jsonrpc?request={"jsonrpc": "2.0", "method":"Input.Right", "params":{}, "id": 1}

My JavaScript returns the following
{"status":200,"statusText":"OK","data":{}}

So it looks like it’s acknowledging the command but nothings happening on screen. I have web interface enabled and I have allow control from both internal and external applications enabled. It all worked fine under Kodi 17 but it does nothing under 18.

#7

I’m not familiar with json but a

  • telnet to port 9090 of my vero4k v18
  • sending: {"jsonrpc": "2.0", "method":"Input.Right", "params":{}, "id": 1}

works, I see a move right in the gui and hear a sound click.

#8

As @joakim_s already told:

See https://kodi.wiki/view/JSON-RPC_API#API_versions and especially the footnote for JSON-RPC version 9, HTTP GET:

“1For information requests only, actions require POST” … and mailing an input request is not a information request.

#9

Because that’s the only apparent difference between 17 and 18 that must be the problem. However when I switched my code to POST it still is not working. I did find a bug in my error reporting call-back and I see I’m getting a parse error that I didn’t realize I was getting invert call back.

I’m doing a POST of the following URL

http://192.168.1.115/jsonrpc?request={"jsonrpc": "2.0", "method":"Input.Right", "params":{}, "id": 1}

And the following is returning

{"status":200,"statusText":"OK","data":{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}}

Is the syntax for POST different than GET?

By the way here is the code that I’m using to post or get

function do_rest(url,cb) {
	var Response;
	var Request = new XMLHttpRequest();
		DebugMessage.innerText= "Debug:"+url;
		Request.onreadystatechange = function() {
		if(Request.readyState == 4) {
			var data= {};
			if (Request.status ==200) data=JSON.parse(Request.responseText);
			Response= {"status":Request.status,"statusText":Request.statusText,"data":data};
			cb(Response);
		}
	}
	Request.open("POST", url, true);
	Request.send();
}
#10

I got it working.

function do_rest(url,s,cb) {
	var Response;
	var Request = new XMLHttpRequest();
	Request.open("POST", url);
	Request.setRequestHeader("Content-Type","application/json");
	Request.onreadystatechange = function() {
		if(this.readyState == XMLHttpRequest.DONE && this.status == 200) {
			var data= {};
			data=JSON.parse(Request.responseText);
			Response= {"status":Request.status,"statusText":Request.statusText,"data":data};
			cb(Response);
		}
	}
	Request.send(s);
}
1 Like
#11

XMLHttpRequest!

+1 for keeping it ‘old school’ and not using a lib.