Hi
I have created below classes for APi response data. But when i try to root.shipmentdata it is not showing
C#
RootShipment root = JsonConvert.DeserializeObject(response.Content);
root.data.
************************
public class RootShipment
{
public bool status { get; set; }
public Data data { get; set; }
}
public class DataShipment
{
public int order_id { get; set; }
public int shipment_id { get; set; }
public string awb_number { get; set; }
public string courier_id { get; set; }
public string courier_name { get; set; }
public string status { get; set; }
public string additional_info { get; set; }
public string payment_type { get; set; }
public string label { get; set; }
}Thanks

Amit MohantyRank #112 · 20K reputationPosted Jan 10, 2023, 11:58 PM EST
You have to declare RootShipment class as below
public class RootShipment { public bool status { get; set; } public DataShipment data { get; set; } }Pasang TamangRank #449 · 5.6K reputationPosted Jan 10, 2023, 11:33 PM EST
Hi,
As per your class structure public Data data { get; set; } should be public DataShipment data { get; set; }.
This is how your class should be
public class RootShipment { public bool status { get; set; } public DataShipment data { get; set; } } public class DataShipment { public int order_id { get; set; } public int shipment_id { get; set; } public string awb_number { get; set; } public string courier_id { get; set; } public string courier_name { get; set; } public string status { get; set; } public string additional_info { get; set; } public string payment_type { get; set; } public string label { get; set; } }Regards,
Pasang
Uday DodiyaRank #239 · 10.3K reputationPosted Jan 11, 2023, 12:26 AM EST
Your subclass is DataShipment, but in your RootShipment class you define the Data class, so you have to mention that class as a DataShipment instead of Data, as per below.
public class RootShipment { public bool status { get; set; } public DataShipment data { get; set; } //problem in this line } public class DataShipment { public int order_id { get; set; } public int shipment_id { get; set; } public string awb_number { get; set; } public string courier_id { get; set; } public string courier_name { get; set; } public string status { get; set; } public string additional_info { get; set; } public string payment_type { get; set; } public string label { get; set; } }