Dear Sir
How to add a Json List inside a JSON Request Body
Please help me out how to call tripSheetEwbBills in this
ConsolateEwayBill
Request Body :
{
"fromPlace": "BANGALORE SOUTH",
"fromState": "29",
"vehicleNo": "PQR9876",
"transMode": "1",
"TransDocNo":null,
"TransDocDate":null,
"tripSheetEwbBills": [
{ "ewbNo": 371002700828 },
{ "ewbNo": 301002700830 },
{ "ewbNo": 341002700832 }
]}
Worked :
private void EwayBill_Extend(string EwayBillNo)
{
string keyid = "Bearer " + APIkey;
string body = "";
string RequestId = Session["User"].ToString() + System.DateTime.Now.ToString("ddmmyyyyhhmmss");
var client = new RestClient("https://gspte.com/test/enriched/ewb/ewayapi?action=VEHEWB");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "*/*");
request.AddHeader("Connection", "keep-alive");
request.AddHeader("Accept-Encoding", "gzip, deflate, br");
request.AddHeader("requestid", "" + RequestId + "");
request.AddHeader("Authorization", "" + keyid + "");
List<tripSheetEwbBills> EList = new List<tripSheetEwbBills>();
EList.Add(new tripSheetEwbBills
{
ewbNo = EwayBillNo
});
ConsolateEwayBill EWayBillExtend = new ConsolateEwayBill()
{
fromPlace = txtFromPlace.Text.ToUpper(),
fromState = txtStateNumber.Text,
vehicleNo = ddlRegisNumber.SelectedValue.Split('>')[0].ToString().Trim(),
transMode = "1",
TransDocNo = null,
TransDocDate = null,
};
body = JsonConvert.SerializeObject(EWayBillExtend);
request.AddParameter("application/json", body, ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
string ms = response.Content;
var Response = JsonConvert.DeserializeObject<root>(ms);
txtEwayBillNo.Text = Response.result.cEwbNo.ToString();
if (Response.success == true)
{
string ValidUp = Convert.ToDateTime(Response.result.cEwbDate.ToString()).ToString("dd-MMM-yyyy");
str = "UPDATE CT_EWAY_BILL_TRANS SET CONS_EWAY_BILL_NO='" + txtEwayBillNo.Text + "',EWAY_BILL_EXTEND_UPTO='" + ValidUp + "', PART_B_GEN='Y',VEHICLE_NUMBER='" + ddlRegisNumber.SelectedValue.Split('>')[0].ToString().Trim() + "',LAST_UPD_USER='" + Session["User"].ToString() + "', " +
"LAST_UPD_DATE=sysdate WHERE DIV_CODE='" + Session["DivCode"].ToString() + "' AND EWAY_BILL_NO='" + EwayBillNo + "' ";
oper.sqedit(str);
}
else
{
}
}
private class ConsolateEwayBill
{
public string fromPlace { get; set; }
public string fromState { get; set; }
public string vehicleNo { get; set; }
public string transMode { get; set; }
public string TransDocNo { get; set; }
public string TransDocDate { get; set; }
public List<tripSheetEwbBills> EwayBills { get; set; }
}
public class tripSheetEwbBills
{
public string ewbNo { get; set; }
}