iRule and JSON-RPC Changes Alpa-7
#1
I was using JSON-RPC via iRule without problem on the 8-31-12 nightly. I have tried to upgrade to Alpha-7 version but it does not seem to be working anymore.

8-31-12 version
Have a iRule network gateway set up with IP 192.168.1.70, port 8082, no userID or password
XBMC webserver on and configured to 8082, no userID or password

The iRule syntax for button "Input.Down" is:
jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1}
this also works:
jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}

Everything works. If I put the following in a browser:
http://192.168.1.70:8082/jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1}
I get:
JSONRPC active and working

[Alpha-7]
Using the exact same configuration (no changes in profile folder). Does not work.
If I put that same string in a browser:
http://192.168.1.70:8082/jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1}
I get:
{
"description": "JSON-RPC API of XBMC",
"id": "http://www.xbmc.org/jsonrpc/ServiceDescription.json",
"methods": {
"Addons.ExecuteAddon": {
[goes on and on]

If I put this in the browser, it works:
http://192.168.1.70:8082/jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}
I get:
{"id":1,"jsonrpc":"2.0","result":"OK"}

I have tried updating the iRule button to reflect the presumedly more restrictive syntax, but no go
[e.g. button now reads jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1} instead of jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1} ]

Not sure what was the purpose of the change made or why it's broken the iRule implementation that was previously working. Any input would be appreciated.

There is nothing on the iRule forum regarding this issue, but since the change was on the XBMC side, and this is all pretty bleeding edge...I'm here...
Reply
#2
(2012-11-04, 18:45)ZestyChicken Wrote: I was using JSON-RPC via iRule without problem on the 8-31-12 nightly. I have tried to upgrade to Alpha-7 version but it does not seem to be working anymore.

8-31-12 version
Have a iRule network gateway set up with IP 192.168.1.70, port 8082, no userID or password
XBMC webserver on and configured to 8082, no userID or password

The iRule syntax for button "Input.Down" is:
jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1}
this also works:
jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}

Everything works. If I put the following in a browser:
http://192.168.1.70:8082/jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1}
I get:
JSONRPC active and working
You do realize that this is just a static dummy response from XBMC? Your JSON-RPC request was not handled by XBMC so it didn't really work.

(2012-11-04, 18:45)ZestyChicken Wrote: [Alpha-7]
Using the exact same configuration (no changes in profile folder). Does not work.
If I put that same string in a browser:
http://192.168.1.70:8082/jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1}
I get:
{
"description": "JSON-RPC API of XBMC",
"id": "http://www.xbmc.org/jsonrpc/ServiceDescription.json",
"methods": {
"Addons.ExecuteAddon": {
[goes on and on]

If I put this in the browser, it works:
http://192.168.1.70:8082/jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}
I get:
{"id":1,"jsonrpc":"2.0","result":"OK"}

I have tried updating the iRule button to reflect the presumedly more restrictive syntax, but no go
[e.g. button now reads jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1} instead of jsonrpc?{"jsonrpc":"2.0","method":"Input.Down","id":1} ]

Not sure what was the purpose of the change made or why it's broken the iRule implementation that was previously working. Any input would be appreciated.

There is nothing on the iRule forum regarding this issue, but since the change was on the XBMC side, and this is all pretty bleeding edge...I'm here...
This is how proper GET requests work. You pass in information through a key-value pair. In this case the key is "request" and the value is your JSON-RPC request. But you need to URL-encode your JSON-RPC request otherwise it will not work. Your webbrowser automatically does this for you if you type
Code:
http://192.168.1.70:8082/jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}
as an URL but iRule obviously doesn't.

So I'm actually wondering how your iRule ever worked because JSON-RPC didn't support HTTP GET requests until I added it 2-3 weeks ago. All you did was calling the default /jsonrpc handler which previously returned "JSONRPC active and working" and now returns the JSON schema describing the JSON-RPC API (which is much more useful).

To fix your problem you need to URL-encode your JSON-RPC requests i.e. for your example you need to use
Code:
http://192.168.1.70:8082/jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Input.Down%22%2C%22id%22%3A1%7D
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#3
First off, thank you very much for the response. Nice someone is out there to help! If can get this working, I will release it to the iRule community and hopefully reduce the amount of posts here!

(2012-11-04, 20:56)Montellese Wrote: You do realize that this is just a static dummy response from XBMC? Your JSON-RPC request was not handled by XBMC so it didn't really work.
Code:
http://192.168.1.70:8082/jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Input.Down%22%2C%22id%22%3A1%7D

Well the cursor moved on the screen so it was working. Interesting the message was wrong...

(2012-11-04, 20:56)Montellese Wrote: This is how proper GET requests work. You pass in information through a key-value pair. In this case the key is "request" and the value is your JSON-RPC request. But you need to URL-encode your JSON-RPC request otherwise it will not work. Your webbrowser automatically does this for you if you type
Code:
http://192.168.1.70:8082/jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}
as an URL but iRule obviously doesn't.

So I'm actually wondering how your iRule ever worked because JSON-RPC didn't support HTTP GET requests until I added it 2-3 weeks ago. All you did was calling the default /jsonrpc handler which previously returned "JSONRPC active and working" and now returns the JSON schema describing the JSON-RPC API (which is much more useful).

To fix your problem you need to URL-encode your JSON-RPC requests i.e. for your example you need to use
Code:
http://192.168.1.70:8082/jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Input.Down%22%2C%22id%22%3A1%7D

No idea why is worked before, but it did...

iRule supports Get/Post/Put so I'm pretty sure it URL-encodes it messages. That said, I had previously tried this without success. I tried again just now, copy/pasting your text in just to see if maybe I encoded it wrong, but still no go.

I wish there was a way for me to check the output in iRule but there isn't to my knowledge (which is not vast LOL but I can google like a mfer!).
Reply
#4
Does it work in your browser (with the URL-encoded request)?
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#5
(2012-11-04, 21:52)Montellese Wrote: Does it work in your browser (with the URL-encoded request)?

Your own does not. I get:
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}

I can't decode your message though either. When I encode the whole url, I get:
Code:
http://192.168.1.70:8082/jsonrpc?request={%22jsonrpc%22:%222.0%22,%22id%22:1,%22method%22:%22Player.PlayPause%22,%22params%22:{%22playerid%22:1}}

This does work. What I had done is just take everything after "http://192.168.1.70:8082/" and plug it into irule. Of course, that's not working either...

If I try to mix the url the way you did, I get:

Code:
http://192.168.1.70:8082/jsonrpc%3Frequest%3D%7B%22jsonrpc%22%3A%222.0%22%2C%22id%22%3A1%2C%22method%22%3A%22Player.PlayPause%22%2C%22params%22%3A%7B%22playerid%22%3A1%7D%7D

Where I plug this into the browser, I get:

File not found


Confusing...
Reply
#6
You only have to encode anything after "request=" i.e. the value of the "request" GET parameter.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#7
So:
http://192.168.1.70:8082/jsonrpc?request={"jsonrpc":"2.0","method":"Input.Down","id":1}
becomes
http://192.168.1.70:8082/jsonrpc?request=
appended to:
%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Input.Down%22%2C%22id%22%3A1%7D

which would be:
http://192.168.1.70:8082/jsonrpc?request...%22%3A1%7D

which works in the browser

so I grab this bit and stick it in iRule:
jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Input.Down%22%2C%22id%22%3A1%7D
[whereas before I had:]
jsonrpc%3Frequest%3D%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Input.Down%22%2C%22id%22%3A1%7D

and the result is...
success!!!!!!

I think I'm going to cry...

Well I'm gonna spend the next fews hours getting every command I can find up and running. Then I'll upload the device to iRule.

Thank you, thank you for your patience!!!
Reply
#8
Can someone tell me from start to finish how to get this to work. I had everything working on Eden and this has totally screwed my system up. I need step by step instructions for setting up gateway for this
Reply

Logout Mark Read Team Forum Stats Members Help
iRule and JSON-RPC Changes Alpa-70