We are trying to write special char in post method but we are getting exception below
can not close the stream until all bytes are written
Below is the example code I am using and below are the special char which I am trying to write
internal static T InvokePostService<T>(string serviceUri, string _data)
{
T _returnResponse = default(T);
HttpWebRequest req = null;
HttpWebResponse res = null;
try
{
string url = serviceUri;
req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/json; charset=utf-8";
req.Timeout = 600000;
req.Headers.Add("SOAPAction", url);
req.ContentLength = _data.Length;
var sw = new StreamWriter(req.GetRequestStream());
sw.Write(_data);
sw.Close();
res = (HttpWebResponse)req.GetResponse();
Stream responseStream = res.GetResponseStream();
var streamReader = new StreamReader(responseStream);
string responseString = streamReader.ReadToEnd();
_returnResponse = JsonConvert.DeserializeObject<T>(responseString);
}
Chars to write : •