Hi
Can anyone provide sample code to upload Eway Bill using GSTZEN Api
Thanks
Hi
Can anyone provide sample code to upload Eway Bill using GSTZEN Api
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jayraj ChhayaRank #304 · 8.2K reputationPosted Apr 17, 2024, 6:22 AM EDT
Hi,
using System; using System.Net.Http; using System.Threading.Tasks; class Program { static async Task Main() { string apiUrl = "https://api.gstzen.in/ewaybill"; string apiKey = "Your_API_Key_Here"; string ewayBillData = "{ \"ewayBillNumber\": \"123456789\", \"date\": \"2022-12-31\" }"; using (HttpClient client = new HttpClient()) { client.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}"); var content = new StringContent(ewayBillData, System.Text.Encoding.UTF8, "application/json"); var response = await client.PostAsync(apiUrl, content); if (response.IsSuccessStatusCode) { Console.WriteLine("EWay Bill uploaded successfully!"); } else { Console.WriteLine("Failed to upload EWay Bill. Error: " + response.ReasonPhrase); } } } }Make sure to replace
"Your_API_Key_Here"with your actual API key provided by GSTZen.Ramco RamcoRank #462 · 5.4K reputationPosted Apr 17, 2024, 6:40 AM EDT
Hi
I am getting error httpresponsemessage does not contain a definition for (response.IsSuccessStatusCode)
Thanks
Jayraj ChhayaRank #304 · 8.2K reputationPosted Apr 17, 2024, 7:02 AM EDT
Hi Ramco Ramco,
Just Deserialize response and check what you get response.
Naimish MakwanaRank #324 · 7.7K reputationPosted Apr 17, 2024, 8:09 AM EDT
Sure, I can help you with that. Here’s a sample code snippet on how you can upload an Eway Bill using the GSTZen API with RestSharp:
var client = new RestClient("https://api.gstzen.in/v1/ewaybill"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Authorization", "Bearer your_api_key_here"); request.AddJsonBody(new { supplyType = "O", subSupplyType = "1", subSupplyDesc = "", docType = "INV", docNo = "sum/1/24/79", docDate = "07/07/2017", fromGstin = "29AAFCC9980M1ZR", fromTrdName = "welton", fromAddr1 = "2ND CROSS NO 59 19 A", fromAddr2 = "GROUND FLOOR OSBORNE ROAD", fromPlace = "FRAZER TOWN", fromPincode = 560090, actFromStateCode = 29, fromStateCode = 29, toGstin = "29AEKPV7203E1Z9", toTrdName = "sthuthya", toAddr1 = "Shree Nilaya", toAddr2 = "Dasarahosahalli", toPlace = "Beml Nagar", toPincode = 560090, actToStateCode = 29, toStateCode = 27, transactionType = 4, otherValue = "0", totalValue = 56099, cgstValue = 0, sgstValue = 0, igstValue = 300.67, cessValue = 400.56, cessNonAdvolValue = 400, totInvValue = 68358, transporterId = "", transporterName = "", transDocNo = "", transMode = "1", transDistance = "100", transDocDate = "", vehicleNo = "PVC1234", vehicleType = "R", itemList = new[] { new { productName = "Wheat", productDesc = "Wheat", hsnCode = 1001, quantity = 4, qtyUnit = "BOX", cgstRate = 0, sgstRate = 0, igstRate = 3, cessRate = 3, cessNonadvol = 0, taxableAmount = 5609889 } } }); IRestResponse response = client.Execute(request);Please replace
"Bearer your_api_key_here"with your actual API key. This code will send a POST request to the GSTZen API with the provided headers and JSON body. The response from the server will be stored in theresponsevariable. You can then check the status of the request and parse the response as needed.Thanks