我正在使用Web API,然后我对webb API进行身份验证并提供错误的用户名或密码,网站返回“远程服务器返回错误:(401)未经授权。”那没关系。 但该网站还将详细信息作为JSON返回,但我无法找到如何访问此信息,然后我得到401异常。
有人有线索吗? 这是我正在使用的代码:
private string Post(string data, string URI)
{
string response = string.Empty;
using (var wc = new WebClient())
{
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
try
{
response = wc.UploadString(URI, data);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
return response;
}
由于