我有一个像 "https://landfill.bugzilla.org/bugzilla-tip/jsonrpc.cgi?method=Product.get¶ms=[{"ids":"4"}]" 这样的 json 网址
我想在 c# 程序中将此作为 URL 传递。下面是代码片段。我怎样才能像上面那样传递像 ids 这样的参数?
try
{
string url="https://landfill.bugzilla.org/bugzilla-tip/jsonrpc.cgi?method=Product.get";
string ret = string.Empty;
StreamWriter requestWriter;
var webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
if (webRequest != null)
{
webRequest.Method = "GET";
webRequest.ServicePoint.Expect100Continue = false;
webRequest.Timeout = 20000;
webRequest.ContentType = "application/json";
}
HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse();
Stream resStream = resp.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
ret = reader.ReadToEnd();
return ret;
}
catch (WebException exception)
{
string responseText;
using (var reader = new StreamReader(exception.Response.GetResponseStream()))
{
responseText = reader.ReadToEnd();
}
return responseText;
}
}
需要传递“ids”作为参数,请帮忙。