The remote server responded with an error: (500) Internal server error

why I get "Remote server returned error: (500) Internal server error." this error this is my code

public override object Request() { Response = ""; RequestTime = DateTime.Now; var url = _service.Url; HttpWebResponse responseObj = null; try { Uri requestUri = null; Uri.TryCreate(url, UriKind.Absolute, out requestUri); CredentialCache cc = new CredentialCache(); NetworkCredential networkCredential = new NetworkCredential("username", "password", url); Uri uri = new Uri(url); cc.Add(uri, "Basic", networkCredential); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); request.Proxy = new WebProxy(url); request.Credentials = cc; request.Method = WebRequestMethods.Http.Post; Response = request.GetResponse(); } catch (Exception x) { Logger.append(x.Message, Logger.ERROR); } Duration = DateTime.Now.Subtract(RequestTime).TotalMilliseconds; return Response; } 

I tried url directly from the browser and it works.

+4
source share
1 answer

If you just go to the URL in the browser, httpMethod will be GET , but you will set it to Post in your code. Perhaps this is why it works in the browser, but not with the code.

I would say that your code is probably good, but is there a site that supports posts for this URL?

+1
source

All Articles