我正在尝试通过 C#/Java 连接到传输 rpc 接口以获取一些信息。 https://trac.transmissionbt.com/browser/trunk/extras/rpc-spec.txt 不幸的是,我无法获得正确的 HTTP-Post 以访问该界面。例如,如果我在 C# 中尝试这个:
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.dll 中发生“System.Net.WebException”类型的未处理异常附加信息:远程服务器返回异常:(409) 冲突。