Hi
I am getting this error - ; expected. It is also saying Version is a type which is not valid in the given context.
C#
var body = @"{
"Version": "1.1",
"TranDtls": {
"TaxSch": "GST",
"SupTyp": "B2B",
"RegRev": "N",
"IgstOnIntra": "N"
},Thanks

Jaimin ShethiyaRank #177 · 13.7K reputationPosted Aug 13, 2024, 7:05 AM EDT
Hello Ramco,
Here is the classes for your json
//var root = JsonConvert.SerializeObject(new Root()); // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); public class BuyerDtls { public string Gstin { get; set; } public string LglNm { get; set; } public string Pos { get; set; } public string Addr1 { get; set; } public string Loc { get; set; } public int Pin { get; set; } public string Stcd { get; set; } } public class DispDtls { public string Nm { get; set; } public string Addr1 { get; set; } public string Loc { get; set; } public int Pin { get; set; } public string Stcd { get; set; } } public class DocDtls { public string Typ { get; set; } public string No { get; set; } public string Dt { get; set; } } public class ItemList { public int ItemNo { get; set; } public string SlNo { get; set; } public string IsServc { get; set; } public string PrdDesc { get; set; } public string HsnCd { get; set; } public int Qty { get; set; } public int FreeQty { get; set; } public string Unit { get; set; } public int UnitPrice { get; set; } public int TotAmt { get; set; } public int Discount { get; set; } public int PreTaxVal { get; set; } public int AssAmt { get; set; } public int GstRt { get; set; } public int IgstAmt { get; set; } public int CgstAmt { get; set; } public int SgstAmt { get; set; } public int CesRt { get; set; } public int CesAmt { get; set; } public int CesNonAdvlAmt { get; set; } public int StateCesRt { get; set; } public int StateCesAmt { get; set; } public int StateCesNonAdvlAmt { get; set; } public int OthChrg { get; set; } public int TotItemVal { get; set; } } public class Root { public string Version { get; set; } public TranDtls TranDtls { get; set; } public DocDtls DocDtls { get; set; } public SellerDtls SellerDtls { get; set; } public BuyerDtls BuyerDtls { get; set; } public DispDtls DispDtls { get; set; } public ShipDtls ShipDtls { get; set; } public List ItemList { get; set; } public ValDtls ValDtls { get; set; } } public class SellerDtls { public string Gstin { get; set; } public string LglNm { get; set; } public string Addr1 { get; set; } public string Loc { get; set; } public int Pin { get; set; } public string Stcd { get; set; } } public class ShipDtls { public string Gstin { get; set; } public string LglNm { get; set; } public string Addr1 { get; set; } public string Loc { get; set; } public int Pin { get; set; } public string Stcd { get; set; } } public class TranDtls { public string TaxSch { get; set; } public string SupTyp { get; set; } public string RegRev { get; set; } public string IgstOnIntra { get; set; } } public class ValDtls { public int AssVal { get; set; } public int CgstVal { get; set; } public int SgstVal { get; set; } public int IgstVal { get; set; } public int CesVal { get; set; } public int StCesVal { get; set; } public int Discount { get; set; } public int OthChrg { get; set; } public int RndOffAmt { get; set; } public int TotInvVal { get; set; } }Jaimin ShethiyaRank #177 · 13.7K reputationPosted Aug 13, 2024, 6:54 AM EDT
Hello Ramco,
Try below code
var body = "{\"Version\": \"1.1\",\"TranDtls\": {\"TaxSch\": \"GST\",\"SupTyp\": \"B2B\",\"RegRev\": \"N\",\"IgstOnIntra\": \"N\"}";Thanks
Ramco RamcoRank #462 · 5.4K reputationPosted Aug 13, 2024, 6:58 AM EDT
Hi jaimin
How i will write this code also in body. Below is the complete requirement
var body = @"{ "Version": "1.1", "TranDtls": { "TaxSch": "GST", "SupTyp": "B2B", "RegRev": "N", "IgstOnIntra": "N" }, "DocDtls": { "Typ": "INV", "No": "23-24/DEM/154", "Dt": "12/08/2024" }, "SellerDtls": { "Gstin": "29AADCG4992P1ZP", "LglNm": "GSTZEN DEMO PRIVATE LIMITED", "Addr1": "Manyata Tech Park", "Loc": "BANGALORE", "Pin": 560077, "Stcd": "29" }, "BuyerDtls": { "Gstin": "06AAMCS8709B1ZA", "LglNm": "Quality Products Private Limited", "Pos": "06", "Addr1": "133, Mahatma Gandhi Road", "Loc": "HARYANA", "Pin": 121009, "Stcd": "06" }, "DispDtls": { "Nm": "Maharashtra Storage", "Addr1": "133, Mahatma Gandhi Road", "Loc": "Bhiwandi", "Pin": 400001, "Stcd": "27" }, "ShipDtls": { "Gstin": "URP", "LglNm": "Quality Products Construction Site", "Addr1": "Anna Salai", "Loc": "Chennai", "Pin": 600001, "Stcd": "33" }, "ItemList": [ { "ItemNo": 0, "SlNo": "1", "IsServc": "N", "PrdDesc": "Computer Hardware - Keyboard and Mouse", "HsnCd": "320504", "Qty": 25, "FreeQty": 0, "Unit": "PCS", "UnitPrice": 200, "TotAmt": 5000, "Discount": 0, "PreTaxVal": 0, "AssAmt": 5000, "GstRt": 18, "IgstAmt": 900, "CgstAmt": 0, "SgstAmt": 0, "CesRt": 0, "CesAmt": 0, "CesNonAdvlAmt": 0, "StateCesRt": 0, "StateCesAmt": 0, "StateCesNonAdvlAmt": 0, "OthChrg": 0, "TotItemVal": 5900 } ], "ValDtls": { "AssVal": 5000, "CgstVal": 0, "SgstVal": 0, "IgstVal": 900, "CesVal": 0, "StCesVal": 0, "Discount": 0, "OthChrg": 0, "RndOffAmt": 0, "TotInvVal": 5900 } }";Thanks
Jaimin ShethiyaRank #177 · 13.7K reputationPosted Aug 13, 2024, 7:00 AM EDT
Hello Ramco,
Prepare the object what you want and then try to serialize that object and use it.