I am trying to connect to a rest api which sends a json response. When I copy paste the url in the browser.Browser gives a pop up to enter username and password.
On entering the username and password (Active directory ID and password), service sends a JSON response. Http request and Response
But trying to connect from code, it returns the following error
{StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Keep-Alive: timeout=15, max=100 Connection: Keep-Alive Date: Wed, 20 Apr 2016 11:38:45 GMT Server: Apache WWW-Authenticate: Basic realm="Login using your AD-ENT credentials, but do not prefix your ID with the domain"
Content-Length: 455 Content-Type: text/html; charset=iso-8859-1 }}
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(@"http://pro.abc.com/services/");
var authData = string.Format("{0}:{1}","username", "password");
var authHeaderValue = Convert.ToBase64String(Encoding.UTF8.GetBytes(authData));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", authHeaderValue);
HttpResponseMessage response = await client.GetAsync("reportpro/reports/11824");