C# (500) 内部服务器错误 - 使用 api 发送 Web 请求时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18713666/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
(500) Internal Server Error - When sending web request using api
提问by FelProNet
I am sending a web request and getting internal server error : 500.
我正在发送 Web 请求并收到内部服务器错误:500。
How can i be sure what side is responsible for getting this error? My side or the external api side?
我如何确定哪一方负责出现此错误?我这边还是外部api那边?
I didn`t see logs in my event viewer.
我没有在我的事件查看器中看到日志。
This is my code:
这是我的代码:
var request = WebRequest.Create("http://saas.appoxee.com/api/") as HttpWebRequest;
request.Method = WebRequestMethods.Http.Post;
request.ContentType = "application/json";
// Add the content to the request
string postDataJsonFormat = CreateExampleTagRequest();
byte[] byteArray = Encoding.UTF8.GetBytes(postDataJsonFormat);
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
// Getting and processing the response
var response = request.GetResponse() as HttpWebResponse;
采纳答案by Belogix
"500.0 – Internal Server Error" is an IIS Error code meaning that the web service is unavailable. This means the error is with the API, not your client.
“ 500.0 – 内部服务器错误”是一个 IIS 错误代码,表示 Web 服务不可用。这意味着错误在于 API,而不是您的客户端。
Summary of server codes:
服务器代码摘要:
1xx - Informational
2xx - Success
3xx - Redirection
4xx - Client error
5xx - Server error
1xx - 信息
2xx - 成功
3xx - 重定向
4xx - 客户端错误
5xx - 服务器错误
For a full list of codes look here: http://support.microsoft.com/kb/943891and about the 500code specifically: http://support.microsoft.com/kb/942031
有关代码的完整列表,请查看此处:http: //support.microsoft.com/kb/943891以及有关500代码的具体信息:http: //support.microsoft.com/kb/942031