I am having this issue more than few days now, and it's very frustrating. I am using a MVC web API application which is working on local and dev server, but unfortunately when I wanted it to deploy on the staging server, I badly got stuck with this issue. Below is the code and options I have tried so far:
private HttpResponseMessage ExecutePostRequest(string url, string body)
{
try
{
HttpContent Body = new StringContent(body);
Body.Headers.ContentType = new MediaTypeWithQualityHeaderValue("application/json");
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("Accept", "application/json");
client.DefaultRequestHeaders.Add("Autorization", "Bearer" + "AccessToken");
HttpResponseMessage response = client.PostAsync(url, Body).Result;
return response;
}
catch (Exception e)
{
WriteLogs(e.ToString(), "Exception");
throw;
}
}
URL I am passing is of some public API like (https://api.powerbi.com/beta----)
I used Proxy settings as below but nothing worked :
<defaultProxy> <proxy usesystemdefault="true" proxyaddress="https://api.powerbi.com" bypassonlocal="True"/> </defaultProxy></system.net>
The above code gives exception as "The ServicePointManager does not support proxies with the https scheme."
I even checked my IE LAN settings. It is not using any proxy settings.
Below is the Stack Trace
[SocketException (0x274d): No connection could be made because the target machine actively refused it] System.Net.Sockets.Socket.BeginConnectEx(EndPoint remoteEP, Boolean flowContext, AsyncCallback callback, Object state) +996 System.Net.Sockets.Socket.UnsafeBeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state) +75 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +480
[WebException: Unable to connect to the remote server] System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) +3366493 System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar) +155
[HttpRequestException: An error occurred while sending the request.]
[AggregateException: One or more errors occurred.] System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) +5863512 SignalR.Dal.Repositories.DashboardRepository.ExecutePostRequest(String url, String body) +475 SignalR.Dal.Repositories.DashboardRepository.GetNominations() +1970 Signal.WebApi.MvcApplication.Application_Start() +359
[HttpException (0x80004005): One or more errors occurred.] System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12600941 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475
[HttpException (0x80004005): One or more errors occurred.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12617988 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12457605
User contributions licensed under CC BY-SA 3.0