PDA

View Full Version : C# need help calling LMS



pkfox
2015-12-16, 04:41
Hi all, I'm trying to get my head around the jsonrpc interface to LMS ( or whatever it's called ) having never done any Web programming it all seems a bit of a black art but here is what I've tried with no success it's c# - It times out



using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleWebRequest
{
class Program
{
static void Main(string[] args)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://10.10.1.11:9000/jsonrpc.js");
request.Credentials = CredentialCache.DefaultCredentials;
request.ContentType = @"application/json";
request.Method = "post";

String JSonCommandStr = Squeezebox.Helpers.SqueezeMessage.CreateMessage("serverstatus");

// This is the string that's returned from the above call
// "{\"id\":1,\"method\":\"slim.request\",\"params\":[null,[\"serverstatus\"]]}"

Stream stream = request.GetRequestStream();
Byte[] bytes = Encoding.Unicode.GetBytes(JSonCommandStr);

stream.Write(bytes, 0, bytes.Length);

// I don't get any error but the connection times out
WebResponse wr = request.GetResponse();


}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}


any ideas guys ?


the server.log shows this which I don't understand either



[15-12-16 11:18:12.6381] Slim::Networking::IO::Select::__ANON__ (131) Error: Select task failed calling Slim::Web::HTTP::processHTTP: '"' expected, at character offset 1 (before "\x{0}"\x{0}i\x{0}d\x{0}...") at /usr/share/perl5/Slim/Web/JSONRPC.pm line 114.

mherger
2015-12-16, 05:31
Enable debugging for network.jsonrpc, control.command and control.queries. This will get you a lot of output, but hopefully some information about your problem, too.

pkfox
2015-12-16, 05:54
Enable debugging for network.jsonrpc, control.command and control.queries. This will get you a lot of output, but hopefully some information about your problem, too.

Thanks Mike where do I do this ?

Edit

It's ok I found it in the web interface settings

pkfox
2015-12-16, 06:40
Enable debugging for network.jsonrpc, control.command and control.queries. This will get you a lot of output, but hopefully some information about your problem, too.

Hi Michael it certainly produces a lot of stuff but nothing showing an error.

pkfox
2015-12-16, 07:57
Don't know what's changed but I see this in server.log



Slim::Web::JSONRPC::handleURI (103) No POST data found => closing connection