Table of Contents

 

 PDF

Pre-requisites for Integrations

TallyPrime can communicate with any environment capable of sending and receiving XML over HTTP. It supports integration with Third Party Applications (like web scripting languages such as ASP/Java/PHP and applications built, which supports XML and HTTP). 

Tally can act as an HTTP Server capable of receiving an XML Requests and responding with an XML Responses. The entire Tally Data can be made available to the requesting application. It is also possible for the application to store data into Tally Database directly without using Tally User Interface. 

Pre-requisites for Integration

Before sending or receiving XML requests from TallyPrime: 

  • TallyPrime must be running on a specific port (for example: 9000). 

  • At least one company must be loaded in Tally. 

Steps to Configure TallyPrime 

  1. Open TallyPrime 

  2. Navigate to Exchange > Data Synchronization.  

  3. The Data Synchronization Configuration screen appears. 

Configure the parameters as given below:

Configuration

Value

TallyPrime act as

Both / Server / Client / None

Enable ODBC

Yes/No

Port

9000 (desired port number)

Note: Make sure the company is loaded. To select a company, Go to Company > Select, it lists the companies created, select the company and load it. 

HTTP Request Format

Every request send to Tally from a third party must contain the information shared below. Tally processes the HTTP request and sends response in XML format itself.

HTTP Request Headers

Information

HTTP method

POST  HTTP/1.1

Host

Localhost:9000

Content-Type

text/xml,UTF-8,UTF-16,ASCII

 

 
 

HTTP Body

Information

Content-Type

text/xml, UTF-8, UTF-16, ASCII

Data

XML request content

Basic XML Request & Response Structure 

A basic XML structure will have an Envelope enclosed tags with Header and Body tags. This basic XML structure will be present in both XML request and response.

<ENVELOPE>

       <HEADER> . . . </HEADER>

       <BODY> . . . </BODY>

</ENVELOPE>

Request Structure 

XML request structure depends on the type of Tally request actions export, import, and execute. A basic XML request will be as follows:

<ENVELOPE>

       <HEADER>

              <VERSION>Version Number</VERSION>

              <TALLYREQUEST>Request Type</TALLYREQUEST>

              <TYPE>Information Type</TYPE>

              <SUBTYPE>Sub Type</SUBTYPE>

              <ID >Identifier</ID>

       </HEADER>

       <BODY>

       <DESC>

           <STATICVARIABLES>Static Variables Specification</STATICVARIABLES>

           <REPEATVARIABLES>Repeat Variables Specification</REPEATVARIABLES>

           <FETCHLIST> Fetch Specification</FETCHLIST>

           <FUNCPARAMLIST> Parameter specification in case of function type 

           </FUNCPARAMLIST>     

              <TDL>   TDL Information     </TDL>

       </DESC>

              <DATA>  Data (if applicable) </DATA>

       </BODY>

</ENVELOPE>

Response Structure 

TallyPrime processes requests and send response accordingly. A basic XML request will be as follows:

<ENVELOPE>

<HEADER>

  <VERSION>Version Number</VERSION>

  <STATUS>-1/0/1</STATUS>

</HEADER>

<BODY>

 <DESC>

     <STATICVARIABLES> Static Variables Specification </STATICVARIABLES>

 </DESC>

 <DATA> Data retrieved (if available)</DATA>

</BODY>

</ENVELOPE>

How to send a request from Third Party Applications to TallyPrime

To send a HTTP request to Tally application following details are required:

Parameter

Details

URL

TallyPrime must be running on a port (e.g., 9000). Example: http://localhost:9000

Headers

Use standard HTTP headers

HTTP Method

POST HTTP/1.1

Host

localhost:9000

Content-Type

Tally supports the following content types:

UTF-8

Default response format. Use for general XML requests.Example: Content-Type: “UTF-8” or Content-Type: “text/XML”

UTF-16

Use for special characters like currency symbols (₹, €).Content must be Unicode encoded.Example: Content-Type: “UTF-16”

ASCII (American Standard Code for Information Interchange)

Specify the content type as ASCII and encode the request content as ASCII encoding to post to Tally, so that Tally respond in ASCII format. Example: Content-Type: “ASCII”

 

POST/Body text – Post/body text will be Tally XML request format.

Sample XML Request: List of Ledgers 

<ENVELOPE>

       <HEADER>

              <VERSION>1</VERSION>

              <TALLYREQUEST>EXPORT</TALLYREQUEST>

              <TYPE>COLLECTION</TYPE>

              <ID>List of Ledgers</ID>

       </HEADER>

       <BODY>

       <DESC>

              <STATICVARIABLES>

                     <SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>

              </STATICVARIABLES>

       </DESC>

       </BODY>

</ENVELOPE>

Set the above parameters and post a request to TallyPrime, it will respond with list of ledgers present in that company.

Here are some of the sample HTTP Post request codes for reference, Request XML need to be replaced with the Tally XML request content.

Samples

Sample PHP Request        

You can include the following code in PHP script to initiate a request

<?php

$request = new HttpRequest();

$request->setUrl(‘http://localhost:9000/’);

$request->setMethod(HTTP_METH_POST);

$request->setHeaders(array(

   ‘cache-control’ => ‘no-cache’,

   ‘content-type’ => ‘text/xml’));

$request->setBody(‘ Request XML ‘);

try {   $response = $request->send();

  echo $response->getBody();

} catch (HttpException $Msg_ex) { echo $Msg_ex;   }    ?>

Sample Java Request

You can include the following code in a Java class to initiate a request

OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse(“text/xml “);

RequestBody body = RequestBody.create(mediaType, “Request XML”);

Request request = new Request.Builder()

  .url(“http://localhost:9000/”)

  .post(body)

  .addHeader(“content-type”, “text/xml”)

  .addHeader(“cache-control”, “no-cache”)

  .build();

Response response = client.newCall(request).execute();

Sample C# Request

Include the following code in a C# class to initiate a request

var client = new RestClient(“http://localhost:9000/”);

var request = new RestRequest(Method.POST);

request.AddHeader(“cache-control”, “no-cache”);

request.AddHeader(“content-type”, “text/xml”);

request.AddParameter(“text/xml”,” Request XML “, ParameterType.RequestBody);

IRestResponse response = client.Execute(request);

Sample VB Request

Include the following code in a VB class to initiate a request

Dim data As String = RequestXML

Dim url As String = “localhost:9000“

Dim myReq As HttpWebRequest = WebRequest.Create(url)

Dim encoding As New UnicodeEncoding

Dim buffer() As Byte = encoding.GetBytes(data)

myReq.AllowWriteStreamBuffering = False

myReq.Method = “POST”

myReq.ContentType = “UTF-16”

myReq.ContentLength = buffer.Length

Dim post As Stream = myReq.GetRequestStream

post.Write(buffer, 0, buffer.Length)

post.Close()

Dim myResponse As HttpWebResponse = myReq.GetResponse

      If myResponse.StatusCode = HttpStatusCode.OK Then

         Dim responsedata As Stream = myResponse.GetResponseStream

         Dim responsereader As StreamReader = New StreamReader

           (responsedata, System.Text.Encoding.Unicode, True)

           response = responsereader.ReadToEnd

           Resp_find.Text = response

     End If

TallyPrime enables seamless integration with third-party applications through XML over HTTP. With simple configurations like setting the port and loading a company, developers can send structured XML requests to exchange data efficiently.

Acting as an HTTP server, TallyPrime supports operations like export, import, and execution. Combined with TDL for data formatting, and standard HTTP methods for communication, this approach allows for reliable automation and system connectivity with minimal effort.

TallyHelpwhatsAppbanner
Is this information useful?
YesNo
Helpful?