I have to access a page from the zendesk.com from my MVC application. I have username and authenticate ticket. When I try to access that page it is returning the error "The remote server returned an error: (401) Unauthorized". Here is the code for the authentication
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");
}