我必须从我的 MVC 应用程序访问 zendesk.com 的页面。我有用户名和身份验证票。当我尝试访问该页面时,它返回错误“远程服务器返回错误:(401)未经授权”。这是身份验证的代码
string authTicket = "asdfsafdsafsdafdsafsf";
username = "user@mysite.com";
string api_url = "https://mysite.zendesk.com/users/current.json";
string base64_creds = Convert.ToBase64String(Encoding.UTF8.GetBytes(username + ":" + authTicket));
HttpWebRequest request = WebRequest.Create(api_url) as HttpWebRequest;
request.Headers.Add("Authorization", "Basic " + base64_creds);
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader reader = new StreamReader(response.GetResponseStream());
string content = reader.ReadToEnd();
//return Content(content);
return View("https://mysite.zendesk.com/entries/mypage");
}