Hey,
Can anyone help me out on how to actually send a command using the JSON/RPC interface? I think I get the logic:
1. Create a JSON object, similar to this:
{"id":1,"method":"slim.request","params":["00:03:0d:d1:70:f4",["play"]]}
2. Send this command to here (using HttpWebRequest):
"http://" + hostName + ":" + portNumber + "/jsonrpc.js";
3. Get the response (using HttpWebResponse)
4. Pull required data from JSON response (for queries).
I'm using C#.NET for Windows Phone 7. Has anyone got any sample code for this?
Here's what I've been messing around with, and I can't even get the object formatted correctly as you can see in the comments:
Code:public void sendCommand(string currentPlayerID, string cmdVal) { string baseUri = "http://" + hostName + ":" + portNumber + "/jsonrpc.js"; SendCommand command = new SendCommand(); command.id = 1; command.method = "slim.request"; command.@params = new string[] {currentPlayerID, cmdVal}; string output = JsonConvert.SerializeObject(command); //intended post: //{"id":1,"method":"slim.request","params":["00:03:0d:d1:70:f4",["play"]]} //actual post: //{"id":1,"method":"slim.request","params":["00:03:0d:d1:70:f4","play"]} ResultBlock.Text = output; HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(new Uri(baseUri + output)); req.Method = "POST"; req.Accept = "application/json"; req.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; SendCommand deserializedProduct = JsonConvert.DeserializeObject<SendCommand>(output); }
Results 1 to 3 of 3
Thread: JSON/RPC Help?
-
2010-05-25, 13:19 #1Junior Member
- Join Date
- Feb 2010
- Posts
- 17
JSON/RPC Help?
-
2010-05-25, 13:21 #2Junior Member
- Join Date
- Feb 2010
- Posts
- 17
I've been using this: http://james.newtonking.com/projects/json/help/
-
2010-05-25, 14:10 #3Junior Member
- Join Date
- Feb 2010
- Posts
- 17
Ohh.. Just found this: http://forums.slimdevices.com/showth...N%2FRPC&page=2

Reply With Quote
