0
我试图通过C#/ Java连接到传输rpc接口来获取一些信息。 https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt 不幸的是我有问题要获取正确的HTTP-Post来访问接口。 例如,如果我尝试在C#:连接到json-rpc接口
using (var client = new WebClient())
{
var values = new NameValueCollection();
values["torrent-get"] = "id";
var response = client.UploadValues("http://ip:9091/transmission/rpc", values);
var responseString = Encoding.Default.GetString(response);
Console.WriteLine("" + responseString);
}
或者,如果我使用:
using (var webClient = new WebClient())
{
String json = "{\"arguments\": {\"fields\": [ \"id\", \"name\", \"totalSize\" ],\"ids\": [ 7, 10 ]},\"method\": \"torrent-get\",\"tag\": 39693}";
var response = webClient.UploadString("http://192.168.240.171:9091/transmission/rpc", "POST", json);
Console.WriteLine(""+response);
}
我得到以下错误:
型System.Net的”未处理的异常。 WebException'发生在System.dll中 附加信息:远程服务器返回了一个异常:(409)冲突。