答案 0 :(得分:0)
您好,请尝试使用此代码,它可能有助于您解决问题,
HttpWebRequest requestObj =
(HttpWebRequest)WebRequest.Create("https://url/token");
requestObj.Method = "POST";
requestObj.PreAuthenticate = true;
requestObj.Headers["Authorization"] = "Basic " + "dato";
requestObj.ContentType = "application/x-www-form-urlencoded";
using (var stream = requestObj.GetRequestStream())
{
//Handle the data for request
//stream.Write();
}
if(requestObj.HaveResponse){
HttpWebResponse responseObj = null;
responseObj = (HttpWebResponse)requestObj.GetResponse();
var strresult = new StreamReader(responseObj .GetResponseStream()).ReadToEnd();
}