Search code examples
c#webrequestsystem.net.webexception

What does WebException Error: Success mean and How to Troubleshoot?


I'm completely at a loss here. The code itself usually works. Every once in a while I end up with this rather cryptic "Success" error instead, however. Rebooting seemed to help once, but now even that doesn't seem to work. I have no idea how to get more information on how to troubleshoot this. Url is always the same and I've verified the "BasicCreds" is returning the proper information (i.e. same as when it works). Any ideas how to troubleshoot further or what this "error" supposedly means?

In case it matters: I'm always behind a proxy and pinging a Jazz RTC server.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("Authorization", BasicCreds());
try
{
    using (WebResponse response = request.GetResponse()) // immediate exception for success (sometimes)
    {

Solution

  • I have no clue what caused the "Success" error, but as suggested, I switched to using HttpClient instead and do not yet have any issues. Here's hoping it remains that way :-)

    HttpClient client = new HttpClient();
    // Modified BasicCreds() to return encoded "username:password" instead of encoded "Basic username:password"
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", BasicCreds());
    try{
         using (HttpResponseMessage response = await client.GetAsync(url))
         {