Hi I'm new to C# and trying to add a http post to scan the library. It works as it should on Kodi but i get an"connection was closed" in c#. Anyone who can guide me in the correct way?
Thanks
Hard to tell without your code. Not that I am a c# user, but someone may be. Alternatively some c# forum which may help you with a json call.
this code sends it to the player and it updates but as i said the connection closes and that gives the error in the C# software. Have been looking at C# forums but nobody seems to have this problem thats why im in the kodi forum =)
string kodiIp = "192.168.1.10";
string port = "9002";
string httpBase = "http://"+kodiIp+":"+port+"/jsonrpc?request=";
JsonSerialize test = new JsonSerialize();
test.jsonrpc = "2.0";
test.method = "VideoLibrary.Scan";
string json = JsonConvert.SerializeObject(test);
using (var webClient = new WebClient())
{
var response = webClient.UploadString(httpBase, "POST", json);
}
FIXED .
string kodiIp = "localhost";
string port = "9002";
string httpBase = "http://" + kodiIp + ":" + port + "/jsonrpc?request=";
JsonSerialize test = new JsonSerialize();
test.jsonrpc = "2.0";
test.method = "VideoLibrary.Scan";
test.id = 1;
string json = JsonConvert.SerializeObject(test);
Console.WriteLine(httpBase + json);
using (var webClient = new WebClient())
{
webClient.Headers.Set("Content-Type", "application/json");
var response = webClient.UploadString(httpBase, "POST", json);
webClient.Dispose();
}
was missing the id property in the test object.