0

I am creating a console application in C# to check if URL is up and running using HttpWebRequest.

Note that the URL is generated by IBM's ICN (IBM Content Navigator). It is NOT hosted using IIS.

I am receiving the below error while trying to get HttpWebResponse from my C# console application. Message: "The remote server returned an error: (500) Internal Server Error." Status: ProtocolError

Below code is not working:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(myurl);

request.Credentials = CredentialCache.DefaultCredentials;

request.Method = "GET";

request.Accept = "text/plain";

request.ContentType = "text/plain;charset=UTF-8";

request.Headers.Add("Accept-Language", "en-US");

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
    if (response != null && response.StatusCode == HttpStatusCode.OK)
    {
        //Do some operations
    }
    else
    {
        //Do some operations
    }
}

Please let me know if additional info. is required.

Any help or suggestions to solve this issue are appreciated.

Thanks in advance.

Sunil Sarda
  • 11
  • 1
  • 1
  • 3
  • Try https instead of http. –  Jul 31 '18 at 18:14
  • I have tried for both HTTP and HTTPS urls but it is not working. I think we need to implement the above code differently for URLs generated by IBM ICC. Please help to solve this issue. – Sunil Sarda Aug 13 '18 at 02:36

0 Answers0