Videolibrary.Scan c#
#1
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
Reply
#2
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.
If I have helped you or increased your knowledge, click the 'thumbs up' button to give thanks :) (People with less than 20 posts won't see the "thumbs up" button.)
Reply
#3
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.
Reply

Logout Mark Read Team Forum Stats Members Help
Videolibrary.Scan c#0