ASP.NET MVC throws the following error in TEST Server, which I could not reproduce in Developer machines.
Trying to connect to WebAPI Service from MVC and getting the error
Only 'http' and 'https' schemes are allowed. Parameter name: requestUri
I could not get an answer from other questions since they are mainly talking about WCF bindings.
Code:
var credentials = "username:Password";
var encoded = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(credentials));
this.client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", encoded);
System.Net.Http.HttpClient client = new HttpClient();
HttpResponseMessage response = client.GetAsync(URL).Result;
Note: Accessing the WebAPI URL through browser returns the data.
URL, can you update your question to show whatURLis being set to?