Issue
While exporting tally data from tally it is supports Multi language texts but while execute xml file from other source like cmd or postman request the Other language texts are return like ???? symbols
My code is
<?xml version="1.0" encoding="UTF-8"?>
<ENVELOPE>
<HEADER>
<TALLYREQUEST>ExportData</TALLYREQUEST>
</HEADER>
<BODY>
<EXPORTDATA>
<REQUESTDESC>
<REPORTNAME>TNetSA LedgerSalesorders</REPORTNAME>
<STATICVARIABLES>
<SVCURRENTCOMPANY>${companyName}</SVCURRENTCOMPANY>
<SVFROMDATE>${fromDate}</SVFROMDATE>
<SVTODATE>${toDate}</SVTODATE>
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>
</STATICVARIABLES>
</REQUESTDESC>
</EXPORTDATA>
</BODY>
</ENVELOPE>
Post request UTF-8
Header=> Content-Type:application/xml; charset=utf-8
https://i.stack.imgur.com/T9WDW.png
UTF-16
Header=> Content-Type:application/xml; charset=utf-16
https://i.stack.imgur.com/S4J7H.png
Using Curl commands
curlcommand = cd C:\Users\..\Data\ && curl -H "Content-Type: text/plain; charset=UTF-8" localhost:9001 --data @Basic\I_SPND.xml
https://i.stack.imgur.com/PJpAK.png
Node js :
const asynchronousProcess = () => {
var inputFilename = Path + 'I_SPND.xml';//path of the stored above xml code
fs.writeFile(inputFilename, values, 'utf8', function (err) {
if (err) {
return console.log(err);
}
});
return new Promise((resolve, reject) => {
let cmd = curlcommand; // above mentioned curl command
exec(cmd, (error, stdout, stderr) => {
if (error) {
reject(error);
}
resolve(stdout ? stdout : stderr);
});
});
}
For eg: If PartyLedgerName is in other language text result will be ????
While running on tally developer tool it supporting multi-language texts but on post request or using curl command means it is not supporting
Solution
Its not about language , its about encoding used in tally to send response
If you are sending request in utf-8 encoding you will get response in utf-8 only
In order to get data from correctly use utf-16 encoding
If you are using any programming language to send request, then you can encode the request xml to utf-16, then you will get response correctly
Postman response with utf-8 encoding
Sending UTF-16 encoded request from postman
Save the xml you are sending in xml in text file and while saving use encoding utf-16
Configuring Postman
In postman under body tab select binary tab and select file you saved in earlier step
In headers tab
Add new Header
Key - Content-Type Value - application/xml; charset=utf-16
Answered By - sai vineeth Answer Checked By - Clifford M. (WPSolving Volunteer)