<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Teja Varma on Medium]]></title>
        <description><![CDATA[Stories by Teja Varma on Medium]]></description>
        <link>https://medium.com/@softwarecodecs?source=rss-5451fadb6690------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*FA0990HBJdjZLyKj</url>
            <title>Stories by Teja Varma on Medium</title>
            <link>https://medium.com/@softwarecodecs?source=rss-5451fadb6690------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 11:18:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@softwarecodecs/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[HTTP Post request — Tally Prime]]></title>
            <link>https://softwarecodecs.medium.com/http-post-request-tally-prime-49d418057a3c?source=rss-5451fadb6690------2</link>
            <guid isPermaLink="false">https://medium.com/p/49d418057a3c</guid>
            <category><![CDATA[tdl]]></category>
            <category><![CDATA[tally-prime]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[tally-erp]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Teja Varma]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 11:13:54 GMT</pubDate>
            <atom:updated>2021-02-04T11:27:43.988Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to send HTTP Post request in Tally Prime</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*or7FKKcE-aMHNmKp0N6iZQ.png" /></figure><p>Here I will show you how to send HTTP POST from the tally prime.</p><p>We need :</p><ol><li>Web Service (to accept and process the request)</li></ol><p>2. DataBase (to store data)</p><p>3. Browser (to display the data)</p><p>We will send a post request from the tally prime contains all the ledgers in the form of JSON.</p><p>Then we will accept the request and parse the JSON body and save them in SQLite3 Database.</p><p>I also created two other pages for displaying ledgers</p><p>Below is the JSON schema which we will send from tally prime</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*hN02P0I9Avbp-9CEOorhxQ.png" /><figcaption>JSON schema — Tally prime</figcaption></figure><p>JSON response from the web service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*pG8djCEIsLdgqG132Esjqw.png" /><figcaption>JSON response — web server</figcaption></figure><p>For web service I used the python-flask framework, you can use any other language of your choice</p><p>For the database, I used the SQlite3 database with python</p><p>Rest API:</p><pre><strong>POST - {Base url}/Ledgers/Add </strong></pre><p>Dynamic Pages:</p><pre><strong>GET - {Base url}/Ledgers/List<br>GET - {Base url}/Ledgers/&lt;string:name&gt;</strong></pre><p>Dynamic pages are used to display the data, either you can view all the ledgers or get one single ledger by passing the name to the URL as shown above.</p><p>Here is the project structure for web service - python (Flask)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*K0am3viii62M6ZRSDpOlRQ.png" /></figure><p>TDL Code:</p><pre>[Collection:LedMasterColl]<br>	Type:Ledger<br>	Fetch:Name,Parent,Address,LedStateName,CountryofResidence,PartyGSTIN<br>	<br>[Collection:LedMastersPost]<br>	Data Source:HTTP JSON:&quot;http://127.0.0.1:5000/Ledgers/Add&quot;<br>	RemoteRequest:LedMasters:UTF8<br>	<br>	<br>[#Menu:GatewayOfTally]<br>	Add:Key Item:PostLedgers:P:Call:PostLedgers<br>	<br>[Function:PostLedgers]<br>	0:Walk Collection:LedMastersPost<br>	2:Msg Box:(IF $Status then &quot;Success&quot; else &quot;Failed&quot;):$Message<br>	3:End Walk<br>	<br><br>[Report:LedMasters]<br>	Form:LedMsaters<br>	Plain JSON:Yes<br>	<br>[Form:LedMsaters]<br>	Part:LedMsaters<br>	JSONTag:&quot;DATA&quot;<br>	<br>[Part:LedMsaters]<br>	Scrolled:Vertical<br>	Line:LedMsaters<br>	Repeat:LedMsaters:LedMasterColl<br>	<br>[Line:LedMsaters]<br>	JSONTag:&quot;LEDGER&quot;<br>	Fields:Ledmst1,Ledmst2,Ledmst3,Ledmst4,Ledmst5,Ledmst6<br>	<br>[Field:Ledmst1]<br>	Set as:$Name<br>	JSONTag:&quot;NAME&quot;<br>	<br>[Field:Ledmst2]<br>	Set as:$Parent<br>	JSONTag:&quot;PARENT&quot;<br>	<br>[Field:Ledmst3]<br>	Set as:$Address<br>	JSONTag:&quot;ADDRESS&quot;<br>	<br>[Field:Ledmst4]<br>	Set as:$LedStateName<br>	JSONTag:&quot;STATE&quot;<br>	<br>[Field:Ledmst5]<br>	Set as:$CountryOfResidence<br>	JSONTag:&quot;COUNTRY&quot;<br>	<br>[Field:Ledmst6]<br>	Set as:$PartyGSTIN<br>	JSONTag:&quot;GSTIN&quot;</pre><p>Python — web service (main.py)</p><p>python packages required:</p><ol><li>Flask</li><li>SQLite 3 (built-in)</li></ol><pre>import sqlite3<br>from flask import Flask, request, jsonify, render_template<br><br>app = Flask(__name__)<br><br><br>@app.route(&#39;/&#39;)<br>def home():<br>    return &quot;&lt;H1&gt;Welcome&lt;/H1&gt;&quot;<br><br><br>@app.route(&#39;/Ledgers/List&#39;)<br>def ledgers():<br>    db = get_db()<br>    db.row_factory = sqlite3.Row<br>    cur = db.cursor()<br>    cur.execute(&quot;select * from Ledgers&quot;)<br>    rows = cur.fetchall()<br>    cur.close()<br>    db.close()<br>    if len(rows) &gt; 0:<br>        return render_template(&quot;Ledgers.html&quot;, data=rows)<br>    else:<br>        return &quot;&lt;center&gt;&lt;H3&gt;No data found&lt;/H3&gt;&lt;/center&gt;&quot;<br><br><br>@app.route(&#39;/Ledgers/&lt;string:name&gt;&#39;, methods=[&#39;GET&#39;])<br>def get_ledger(name):<br>    db = get_db()<br>    db.row_factory = sqlite3.Row<br>    cur = db.cursor()<br>    cur.execute(&quot;select * from Ledgers where name = ?&quot;, [name])<br>    row = cur.fetchone()<br>    cur.close()<br>    db.close()<br>    if row:<br>        return render_template(&quot;Ledger.html&quot;, led=row)<br>    else:<br>        return &quot;&lt;center&gt;&lt;H3&gt;No data found&lt;/H3&gt;&lt;/center&gt;&quot;<br><br><br>@app.route(&#39;/Ledgers/Add&#39;, methods=[&#39;POST&#39;])<br>def add_ledgers():<br>    data = request.get_json()<br>    db = get_db()<br>    try:<br>        for led in data[&#39;DATA&#39;][&#39;LEDGER&#39;]:<br>            name = led[&quot;NAME&quot;]<br>            group = led[&quot;PARENT&quot;]<br>            address = led[&quot;ADDRESS&quot;] if &quot;ADDRESS&quot; in led else &quot;NIL&quot;<br>            state = led[&quot;STATE&quot;] if &quot;STATE&quot; in led else &quot;NIL&quot;<br>            country = led[&quot;COUNTRY&quot;] if &quot;COUNTRY&quot; in led else &quot;NIL&quot;<br>            gst = led[&quot;GSTIN&quot;] if &quot;GSTIN&quot; in led else &quot;NIL&quot;<br>            db.execute(&quot;INSERT INTO Ledgers (name,parent,address,state,country,gstin) VALUES(?,?,?,?,?,?)&quot;,<br>                       (name, group, address, state, country, gst))<br>            db.commit()<br>    except Exception as e:<br>        print(e)<br>        return jsonify(status=False, message=str(e))<br>    finally:<br>        db.close()<br>    return jsonify(status=True, message=&quot;Ledgers inserted successfully&quot;)<br><br><br>def get_db():<br>    db = sqlite3.connect(&quot;ledgers.db&quot;)<br>    db.execute(<br>        &quot;CREATE TABLE IF NOT EXISTS Ledgers (id INTEGER PRIMARY KEY AUTOINCREMENT,name TEXT,parent TEXT,address TEXT,state TEXT,country TEXT,gstin TEXT)&quot;)<br>    db.commit()<br>    return db<br><br><br>if __name__ == &quot;__main__&quot;:<br>    app.run(debug=True)<br></pre><p>Dynamic web page — Getting the list of ledgers:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;List Of Ledgers&lt;/title&gt;<br>    &lt;style&gt;<br><br>        body{<br>        font-family:sans-serif<br>        }<br>        h2{<br>        color:tomato;<br>        text-decoration:underline<br>        }<br>        table{<br>        width:100%<br>        }<br>        table,th,td{<br>        border: 1px solid black;<br>        border-collapse: collapse;<br>        border-spacing: 5px;<br>        }<br>        th, td {<br>       padding: 15px;<br>       }<br>       th{<br>       color:white;<br>       background-color:green<br>       }<br>        td{<br>        background-color:rgba(255, 99, 71, 0.5);<br>        font-weight:bold<br>        }<br><br><br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;center&gt;&lt;H2&gt;LEDGERS&lt;/H2&gt;&lt;/center&gt;<br>&lt;table&gt;<br>    &lt;tr&gt;<br>        &lt;th&gt;NAME&lt;/th&gt;<br>        &lt;th&gt;GROUP&lt;/th&gt;<br>        &lt;th&gt;ADDRESS&lt;/th&gt;<br>        &lt;th&gt;STATE&lt;/th&gt;<br>        &lt;th&gt;COUNTRY&lt;/th&gt;<br>        &lt;th&gt;GSTIN&lt;/th&gt;<br>    &lt;/tr&gt;<br>    {% for led in data %}<br>    &lt;tr&gt;<br>        &lt;td&gt;{{led[&quot;name&quot;]}}&lt;/td&gt;<br>        &lt;td&gt;{{led[&quot;parent&quot;]}}&lt;/td&gt;<br>        &lt;td&gt;{{led[&quot;address&quot;]}}&lt;/td&gt;<br>        &lt;td&gt;{{led[&quot;state&quot;]}}&lt;/td&gt;<br>        &lt;td&gt;{{led[&quot;country&quot;]}}&lt;/td&gt;<br>        &lt;td&gt;{{led[&quot;gstin&quot;]}}&lt;/td&gt;<br>    &lt;/tr&gt;<br>    {% endfor %}<br>&lt;/table&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Dynamic web page — for getting Ledger by name</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;{{ led[&quot;name&quot;] }}&lt;/title&gt;<br>    &lt;style&gt;<br><br>        body{<br>        font-family:sans-serif<br>        }<br>        h3{<br>        color:tomato;<br>        }<br>        table{<br>        width:100%<br>        }<br>        table,td{<br>        border: 1px solid black;<br>        border-collapse: collapse;<br>        border-spacing: 5px;<br>        }<br>        td {<br>       padding: 15px;<br>       }<br>        td{<br>        background-color:rgba(255, 99, 71, 0.5);<br>        font-weight:bold<br>        }<br><br><br><br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;H3&gt;(Ledger - {{ led[&quot;name&quot;] }})&lt;/H3&gt;<br>&lt;table&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;NAME&lt;/td&gt;<br>        &lt;td&gt;{{ led[&quot;name&quot;] }}&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;GROUP&lt;/td&gt;<br>        &lt;td&gt;{{ led[&quot;parent&quot;] }}&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;ADDRESS&lt;/td&gt;<br>        &lt;td&gt;{{ led[&quot;address&quot;] }}&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;STATE&lt;/td&gt;<br>        &lt;td&gt;{{ led[&quot;state&quot;] }}&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;COUNTRY&lt;/td&gt;<br>        &lt;td&gt;{{ led[&quot;country&quot;] }}&lt;/td&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;GSTIN&lt;/td&gt;<br>        &lt;td&gt;{{ led[&quot;gstin&quot;] }}&lt;/td&gt;<br>    &lt;/tr&gt;<br>&lt;/table&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Steps to run it</p><ol><li>Load the TDL Code in Tally Prime</li><li>Run python file -main.py</li><li>Open Tally Prime and click on Post Ledgers option in GatewayOfTally</li><li>Then open browser and goto -&gt; localhost:5000/Ledgers/List</li><li>For getting single ledger goto -&gt; localhost:5000/Ledgers/&lt;name&gt;</li></ol><p>Check out my GitHub repo for stuff like this: <a href="https://github.com/tejavarma-aln">https://github.com/tejavarma-aln</a></p><p>Follow me on</p><p>Facebook: <a href="https://www.facebook.com/Softcdc">https://www.facebook.com/Softcdc</a></p><p>Telegram: <a href="https://t.me/tdlcommunity">https://t.me/tdlcommunity</a></p><p>Thank you!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49d418057a3c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>