Click here to Skip to main content
15,896,349 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Please help me, how to solve this issue

What I have tried:

<pre> public static string SendRequest(string webRequeststr)
        {

            String rersponsestr = "";
            String result = "";

            String lTallyLocalHost = "http://localhost:9000";

            HttpWebRequest httprequest = (HttpWebRequest)WebRequest.Create(lTallyLocalHost);
            httprequest.Method = "POST";

            httprequest.ContentLength = (long)webRequeststr.Length;
            httprequest.ContentType = "application/x-www-form-urlencoded";
            StreamWriter stream = new StreamWriter(httprequest.GetRequestStream());
            stream.Write(webRequeststr);
            stream.Close();
            HttpWebResponse httpresponse = (HttpWebResponse)httprequest.GetResponse();
            Stream recivestream = httpresponse.GetResponseStream();
            StreamReader streamreader = new StreamReader(recivestream, Encoding.UTF8);
            rersponsestr = streamreader.ReadToEnd();
            httpresponse.Close();
            streamreader.Close();

            result = rersponsestr;
            return result;
        }


        private void ledgerCreateXML(RequestData req)
        {
            try
            {
                String XmlContent = "";
                XmlContent = XmlContent + "<ENVELOPE>\r\n";
                XmlContent = XmlContent + "<HEADER>\r\n";
                XmlContent = XmlContent + "<TALLYREQUEST>Import Data From CSM</TALLYREQUEST>\r\n";
                XmlContent = XmlContent + "</HEADER>\r\n";
                XmlContent = XmlContent + "<BODY>\r\n";
                XmlContent = XmlContent + "<IMPORTDATA>\r\n";
                XmlContent = XmlContent + "<REQUESTDESC>\r\n";
                XmlContent = XmlContent + "<REPORTNAME>All Masters</REPORTNAME>\r\n";
                XmlContent = XmlContent + "</REQUESTDESC>\r\n";
                XmlContent = XmlContent + "<REQUESTDATA>\r\n";
                XmlContent = XmlContent + "<TALLYMESSAGE xmlns:UDF="+"\""+"TallyUDF"+"\">\r\n";

                XmlContent = XmlContent + "<LEDGER NAME="+"\""+req.LedgerName+"\"Action="+"\""+"Create"+"\">\r\n";
                XmlContent = XmlContent + "<NAME>"+req.LedgerName+"</NAME>\r\n"; 
                XmlContent = XmlContent + "<PARENT>"+req.ParentName+"</PARENT>\r\n";
                XmlContent = XmlContent + "<OPENINGBALANCE>"+req.OpeningBalance+ "</OPENINGBALANCE>\r\n";
                XmlContent = XmlContent + "<ISBILLWISEON>Yes</ISBILLWISEON>\r\n";
                XmlContent = XmlContent + "</LEDGER>\r\n";
                XmlContent = XmlContent + "</TALLYMESSAGE>\r\n";
                XmlContent = XmlContent + "</REQUESTDATA>\r\n";
                XmlContent = XmlContent + "</IMPORTDATA>\r\n";
                XmlContent = XmlContent + "</BODY>\r\n";
                XmlContent = XmlContent + "</ENVELOPE>\r\n";

                String xmldata = XmlContent;
                String ledgerresponse = SendRequest(xmldata);



            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
Posted
Updated 28-Oct-20 23:07pm
Comments
Richard MacCutchan 28-Jul-20 15:37pm    
Check the message at the server to see that it is correctly formed. In particular check the entry for TALLYMESSAGE.
Member 14901284 28-Jul-20 23:50pm    
Hey Richard thanks for replying, how i check the message at server? i install Tally ERP 9 and its odbc server run on 9000 and when i enter localhost:9000 it showing me that <response>Tally Erp server is running
Richard MacCutchan 29-Jul-20 3:21am    
Sorry, no idea. I suggest you read the documentation.

Maybe the Tally API documentation will be helpful:
Integration using XML Interface[^]

http://mirror1.tallysolutions.com/Downloads/TDL%20Developer/Tally.ERP%209%20-%20Integration%20Capabilities.pdf
 
Share this answer
 
v2
Step 1)Open Tally application Check whether tally port is working or not on http://localhost:9000
You can also change it.
Step 2) Follow Below code for reference and replace your Value my value(objdata).
String lResponseStr = "";
                   String xmlstc = "";
                   xmlstc = "<ENVELOPE>\r\n";
                   xmlstc = xmlstc + "<HEADER>\r\n";
                   xmlstc = xmlstc + "<TALLYREQUEST>Import Data</TALLYREQUEST>\r\n";
                   xmlstc = xmlstc + "</HEADER>\r\n";
                   xmlstc = xmlstc + "<BODY>\r\n";
                   xmlstc = xmlstc + "<IMPORTDATA>\r\n";
                   xmlstc = xmlstc + "<REQUESTDESC>\r\n";
                   xmlstc = xmlstc + "<REPORTNAME>All Masters</REPORTNAME>\r\n";
                   xmlstc = xmlstc + "<STATICVARIABLES><SVCURRENTCOMPANY>Pratik </SVCURRENTCOMPANY></STATICVARIABLES>\r\n";
                   xmlstc = xmlstc + "</REQUESTDESC>\r\n";
                   xmlstc = xmlstc + "<REQUESTDATA>\r\n";
                   xmlstc = xmlstc + "<TALLYMESSAGE xmlns:UDF=" + "\"" + "TallyUDF" + "\">\r\n";
                   xmlstc = xmlstc + "<LEDGER NAME=" + "\"" + objData.Rows[i]["title"] + objData.Rows[i]["partyname"] + "\" Action =" + "\"" + "Create" + "\">\r\n";
                   xmlstc = xmlstc + "<NAME>" + objData.Rows[i]["title"] + objData.Rows[i]["partyname"] + "</NAME>\r\n";
                   xmlstc = xmlstc + "<PARENT>Sundry Debtors</PARENT>\r\n";
                   xmlstc = xmlstc + "<ADDRESS.LIST><ADDRESS>" + objData.Rows[i]["vinstaddress"] + ",City :" + objData.Rows[i]["city"] + ",Route :" + objData.Rows[i]["route"] + "</ADDRESS></ADDRESS.LIST>\r\n";
                   xmlstc = xmlstc + "<EMAIL>" + objData.Rows[i]["vinstemail"] + "</EMAIL>\r\n";
                   xmlstc = xmlstc + "<LEDGERMOBILE>" + objData.Rows[i]["vinsttel1"] + "</LEDGERMOBILE>\r\n";
                   xmlstc = xmlstc + "<LEDGERPHONE>" + objData.Rows[i]["vbilltel1"] + "</LEDGERPHONE>\r\n";
                   xmlstc = xmlstc + "<PINCODE>" + objData.Rows[i]["vinstpostalcode"] + "</PINCODE>\r\n";
                   xmlstc = xmlstc + "<WEBSITE>" + objData.Rows[i]["vwebsite"] + "</WEBSITE>\r\n";
                   xmlstc = xmlstc + "<LEDGERFAX>" + objData.Rows[i]["vinstfax"] + "</LEDGERFAX>\r\n";
                   xmlstc = xmlstc + "<LEDGERCONTACT>" + objData.Rows[i]["contactperson"] + "</LEDGERCONTACT>\r\n";
                   xmlstc = xmlstc + "<COUNTRYNAME>India</COUNTRYNAME>\r\n";
                   xmlstc = xmlstc + "</LEDGER>\r\n";
                   xmlstc = xmlstc + "</TALLYMESSAGE>\r\n";
                   xmlstc = xmlstc + "</REQUESTDATA>\r\n";
                   xmlstc = xmlstc + "</IMPORTDATA>\r\n";
                   xmlstc = xmlstc + "</BODY>";
                   xmlstc = xmlstc + "</ENVELOPE>";
                   try
                   {
                       String lTallyLocalHost = "http://localhost:9000";
                       HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(lTallyLocalHost);
                       httpWebRequest.Method = "POST";
                       httpWebRequest.ContentLength = (long)xmlstc.Length;
                       httpWebRequest.ContentType = "application/x-www-form-urlencoded";
                       StreamWriter lStrmWritr = new StreamWriter(httpWebRequest.GetRequestStream());
                       lStrmWritr.Write(xmlstc);
                       lStrmWritr.Close();
                       HttpWebResponse lhttpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                       Stream lreceiveStream = lhttpResponse.GetResponseStream();
                       StreamReader lStreamReader = new StreamReader(lreceiveStream, Encoding.UTF8);
                       lResponseStr = lStreamReader.ReadToEnd();
                       lhttpResponse.Close();
                       lStreamReader.Close();
                   }
 
Share this answer
 
v8
Comments
CHill60 29-Oct-20 5:44am    
Putting your email out onto an open forum is just inviting spam
Siddharth11041996 29-Oct-20 6:25am    
Please open your tally and check company is open or shut. Please select the company before sending the data
above code is error less,Please refer above code and replace my value with yours
CHill60 29-Oct-20 6:57am    
I am not the OP. I was trying to stop you from being spammed.
Richard Deeming 29-Oct-20 6:08am    
Using string concatenation to build an XML document is an extremely bad idea. If your data contains any "special" characters, you will end up with a malformed document.

.NET has at least two built-in ways of creating XML documents which will avoid this problem, and will almost certainly have better performance than repeated string concatenation.
Siddharth11041996 29-Oct-20 6:21am    
This is the simplest Way to build a xml format and pass to tally.Before Entering the special character Please insert that special character into the tally and then pass to c#.
If tally accecpt that value there is no problem on c# backend side.To pass special characeter pass it into the double quote thats it


Please refer above code and replace my value with yours

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900