Tally Integration with XML and HTTP : Ledger creation failure

生来就可爱ヽ(ⅴ<●) 提交于 2020-08-05 06:18:30

问题


I would like to integrate a third party application with tally over HTTP using XML. When I try to import a ledger into tally through HTTP, it says Unknown Request, cannot be processed

Same XML format, when I import into tally manually using "Import Data" from "Gateway of Tally", it imports without errors and the ledger is created.

Am I missing any HTTP headers? Currently, I have "Content-Type" set to "text/xml"; i also tried with "text/xml;charset=utf-16";

With the same headers, there are other tally XML requests working when I tried in the same way

 <!-- language: xml -->
    <?xml version="1.0" encoding="UTF-8"?>
<ENVELOPE>
  <HEADER>
    <TALLYREQUEST>Import Data</TALLYREQUEST>
  </HEADER>
  <BODY>
    <IMPORTDATA>
      <REQUESTDESC>
        <STATICVARIABLES>
          <SVCURRENTCOMPANY>Test</SVCURRENTCOMPANY>
        </STATICVARIABLES>
      </REQUESTDESC>
      <REQUESTDATA>
        <TALLYMESSAGE xmlns:UDF="TallyUDF">
          <LEDGER NAME="name2" RESERVEDNAME="">
            <ADDRESS.LIST TYPE="String">
              <ADDRESS>line1, line2</ADDRESS>
              <ADDRESS>city</ADDRESS>
            </ADDRESS.LIST>
            <LEDSTATENAME>Goa</LEDSTATENAME>
            <PINCODE>403001</PINCODE>
            <MAILINGNAME.LIST TYPE="String">
              <MAILINGNAME>name2</MAILINGNAME>
            </MAILINGNAME.LIST>
            <CURRENCYNAME>₹</CURRENCYNAME>
            <EMAIL>testvira@email.com</EMAIL>
            <WEBSITE />
            <INCOMETAXNUMBER>LSWI2278DF</INCOMETAXNUMBER>
            <COUNTRYNAME>India</COUNTRYNAME>
            <GSTREGISTRATIONTYPE>Regular</GSTREGISTRATIONTYPE>
            <PARENT>Sundry Debtors - Viras</PARENT>
            <NARRATION />
            <COUNTRYOFRESIDENCE>India</COUNTRYOFRESIDENCE>
            <EMAILCC>mysteryman@email.com</EMAILCC>
            <LEDGERPHONE>458923</LEDGERPHONE>
            <LEDGERCONTACT>Mystery Man</LEDGERCONTACT>
            <LEDGERMOBILE>6598765987</LEDGERMOBILE>
            <PARTYGSTIN>ASDF234kl56</PARTYGSTIN>
            <GSTNATUREOFSUPPLY>SEZ</GSTNATUREOFSUPPLY>
            <LANGUAGENAME.LIST>
              <NAME.LIST TYPE="String">
                <NAME>name2</NAME>
                <NAME>new name2</NAME>
              </NAME.LIST>
              <LANGUAGEID>1033</LANGUAGEID>
            </LANGUAGENAME.LIST>
            <PAYMENTDETAILS.LIST>
              <IFSCODE>ifsc code</IFSCODE>
              <BANKNAME>ScamNo1</BANKNAME>
              <ACCOUNTNUMBER>123456789</ACCOUNTNUMBER>
              <PAYMENTFAVOURING>name2</PAYMENTFAVOURING>
              <TRANSACTIONNAME>E-Payment</TRANSACTIONNAME>
              <SETASDEFAULT>No</SETASDEFAULT>
              <DEFAULTTRANSACTIONTYPE>Inter Bank Transfer</DEFAULTTRANSACTIONTYPE>
              <BENEFICIARYCODEDETAILS.LIST />
            </PAYMENTDETAILS.LIST>
            <LEDMULTIADDRESSLIST.LIST>
              <ADDRESS.LIST TYPE="String">
                <ADDRESS>Door No 1</ADDRESS>
                <ADDRESS>Road No 1</ADDRESS>
                <ADDRESS>Semmedu</ADDRESS>
              </ADDRESS.LIST>
              <EMAIL />
              <STATE>Tamil Nadu</STATE>
              <PINCODE>641114</PINCODE>
              <INCOMETAXNUMBER>LSWI2278DF</INCOMETAXNUMBER>
              <COUNTRYNAME>India</COUNTRYNAME>
              <GSTREGISTRATIONTYPE>Regular</GSTREGISTRATIONTYPE>
              <ADDRESSNAME>City Office</ADDRESSNAME>
              <PARTYGSTIN>ASDF234kl56</PARTYGSTIN>
              <CONTACTPERSON>maverick</CONTACTPERSON>
              <ISOTHTERRITORYASSESSEE>No</ISOTHTERRITORYASSESSEE>
            </LEDMULTIADDRESSLIST.LIST>
            <LEDMULTIADDRESSLIST.LIST>
              <ADDRESS.LIST TYPE="String">
                <ADDRESS>Door No 1</ADDRESS>
                <ADDRESS>Road No 1</ADDRESS>
                <ADDRESS>Semmedu</ADDRESS>
              </ADDRESS.LIST>
              <EMAIL />
              <STATE>Tamil Nadu</STATE>
              <PINCODE>641114</PINCODE>
              <INCOMETAXNUMBER>LSWI2278DF</INCOMETAXNUMBER>
              <COUNTRYNAME>India</COUNTRYNAME>
              <GSTREGISTRATIONTYPE>Regular</GSTREGISTRATIONTYPE>
              <ADDRESSNAME>Godown</ADDRESSNAME>
              <PARTYGSTIN>ASDF234kl56</PARTYGSTIN>
              <CONTACTPERSON>maverick</CONTACTPERSON>
              <ISOTHTERRITORYASSESSEE>No</ISOTHTERRITORYASSESSEE>
            </LEDMULTIADDRESSLIST.LIST>
          </LEDGER>
        </TALLYMESSAGE>
      </REQUESTDATA>
    </IMPORTDATA>
  </BODY>
</ENVELOPE>

I expect the output to be an XML which says ledger created but the actual output is Unknown Request, cannot be processed


回答1:


Quite late at seeing this, but if you still need an answer. Make the following changes to your XML -

Make your Header as follows -

  <HEADER>
    <VERSION>1</VERSION>
    <TALLYREQUEST>IMPORT</TALLYREQUEST>
    <TYPE>DATA</TYPE>
    <ID>ALL MASTERS</ID>
  </HEADER>

Next within the Body Tag, remove the RequestDesc and RequestData tags and change the structure to -

  <BODY>
    <DESC>
      <STATICVARIABLES>
        <SVCURRENTCOMPANY>Test</SVCURRENTCOMPANY>
      </STATICVARIABLES>
    </DESC>
    <DATA>
      <TALLYMESSAGE>
        <LEDGER ACTION="CREATE">
           <NAME>name2</NAME>
           //OTHER LEDGER DETAILS GO HERE (same as you did with no changes)
        </LEDGER>
      </TALLYMESSAGE>
    <DATA>
  </BODY>

NOTE - You need to create the XML Attribute ACTION and assign the value CREATE. This is exactly similar to when you create a new ledger in Tally through their GUI - which is going to "Accounts Info > Ledgers > Create" and similarly if you want to alter a ledger then set the ACTION="ALTER"




回答2:


<RequestDesc>, <RequestData> tags are only for export for import, it is <Desc> ,<Data>




回答3:


Maybe I am too late to answer this question. Even I had this problem, but finally I found out that problem was due to the character encoding of the XML file. What I did is as follows:

Goto SaveAs > Select- AllFiles > yourfilename.xml

(Below will be a character encoding dropdown choose- ANSI or UTF-8 only )

This resolved my problem and I was able to POST the XML file.

Hope it helps.



来源:https://stackoverflow.com/questions/55723365/tally-integration-with-xml-and-http-ledger-creation-failure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!