通过POST请求提交CSV - POST通过空(c#)
本文关键字:POST 请求 提交 CSV 通过 | 更新日期: 2023-09-27 17:50:00
我正试图从文件中读取CSV并通过POST请求提交。由于某些原因,请求中没有发送数据。有人能看到我的代码出了什么问题吗?
FileStream rdr = new FileStream(path, FileMode.Open, FileAccess.Read);
byte[] inData = new byte[rdr.Length];
rdr.Read(inData, 0, Convert.ToInt32(rdr.Length));
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.KeepAlive = false;
req.ContentType = GetContentType(path);
req.Method = "POST";
req.ContentLength = rdr.Length;
req.AllowWriteStreamBuffering = true;
Stream reqStream = req.GetRequestStream();
reqStream.Write(inData, 0, Convert.ToInt32(rdr.Length));
Stream dataStream = req.GetResponse().GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
responseFromServer = responseFromServer + reader.ReadToEnd();
rdr.Close();
reqStream.Close();
我确定CSV数据需要作为变量的值提交。我发邮件的第三方可能会事先提到这一点。谢谢你的帮助。