public static string SentHttpRequestAlert(string alertid, string project, string alert_type, string alert_subtype, string product, string location, string workorder, string process, string zerenren, string manager, string sb, string last_remark)
{
WebRequest request = WebRequest.Create(“http://10.132.41.128:9001/newevent”);
request.Method = “POST”;
byte[] byteArray = Encoding.UTF8.GetBytes(“{“content”:{“id”:”” + alertid + “”,”project”: “” + project + “”,”alert_type”: “” + alert_type + “”,”alert_content”:”” + alert_subtype + “”,”product”: “” + product + “”,”location”: “” + location + “”,”description”: “” + workorder + “”,”process”:”” + process + “”,”owner”: “” + zerenren + “”,”manager”:”” + manager + “”,”department”: “” + sb + “”,”last_remark”: “” + last_remark + “”}}”);
//request.ContentType = “text/xml”;
request.ContentType = “application/x-www-form-urlencoded”;
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
{
WebRequest request = WebRequest.Create(“http://10.132.41.128:9001/newevent”);
request.Method = “POST”;
byte[] byteArray = Encoding.UTF8.GetBytes(“{“content”:{“id”:”” + alertid + “”,”project”: “” + project + “”,”alert_type”: “” + alert_type + “”,”alert_content”:”” + alert_subtype + “”,”product”: “” + product + “”,”location”: “” + location + “”,”description”: “” + workorder + “”,”process”:”” + process + “”,”owner”: “” + zerenren + “”,”manager”:”” + manager + “”,”department”: “” + sb + “”,”last_remark”: “” + last_remark + “”}}”);
//request.ContentType = “text/xml”;
request.ContentType = “application/x-www-form-urlencoded”;
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
//WebResponse response = request.GetResponse();
WebResponse response;
try
{
response = (WebResponse)request.GetResponse();
}
catch (WebException ex)
{
response = (WebResponse)ex.Response;
}
Console.WriteLine(((HttpWebResponse)response).StatusDescription);//定义response字符流
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();//读取全部
//关闭资源
reader.Close();
dataStream.Close();
response.Close();
}
return responseFromServer;
解决方案:5分
你都把它的流给释放掉了还获取个啥
解决方案:35分
对方数据库大小能否受到限制,所以返回你空值,导致你出错