This is the code that I am using and output I am receiving.
Output:
� ��.Yk{�1�<�";����������B�Ze�z ������"�脙��w�3�嵪���5���V�X5��OIdY���/�$���Z�d��%� ����}}����;r?(ۄ�?xS#%�Da���$�dʩ�V��g2_F���.�����/��
In this Line:
Stream requestStream = request.GetRequestStream();
requestStream.Length
and requestStream.Position
threw an exception of type System.NotSupportedException
public void Test() {
string xmlMessage = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>" +
"<HEADER>" +
"<ID>Ram</ID>" +
"<SOURCE></SOURCE>" +
"<TARGET></TARGET>" +
"<CONTENT-TYPE>text/xml;charset=utf-8</CONTENT-TYPE>" +
"</HEADER>" +
"<ENVELOPE>" +
"<VERSION></VERSION>" +
"<REQVERSION></REQVERSION>" +
"<TALLYREQUEST></TALLYREQUEST>" +
"<TYPE></TYPE>" +
"<ID></ID>" +
"<CONTENT-TYPE>/xml;charset=utf-8</CONTENT-TYPE>" +
"<SESSIONID></SESSIONID>" +
"<TOKEN></TOKEN>" +
"<BODY>" +
"<DESC>" +
"<STATICVARIABLES>" +
"<SVINCLUDE></SVINCLUDE>" +
"</STATICVARIABLES>" +
"</DESC>" +
"</BODY>" +
"</ENVELOPE>";
//Sending the request to Tally test URL address
string url = "www.xxxxxxx.com";
//create a request
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = false;
request.ProtocolVersion = HttpVersion.Version10;
request.Method = "POST";
string postData = xmlMessage;
// turn our request string into a byte stream
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
//byte[] requestInFormOfBytes = new UTF8Encoding(false).GetBytes(xmlMessage);
request.ContentType = "text/xml;charset=utf-8";
request.ContentLength = byteArray.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(byteArray, 0, byteArray.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader respStream = new StreamReader(response.GetResponseStream(), System.Text.Encoding.UTF8);
string receivedResponse = respStream.ReadToEnd();
Label2.Text = receivedResponse;
respStream.Close();
response.Close();
}