Hi
I am getting this error -
| Name | Value | Type | |
|---|---|---|---|
| ? | $exception | {"The best overloaded method match for 'NimbusAPi.AwbTracking.GetData(string)' has some invalid arguments"} | Microsoft.CSharp.RuntimeBinder.RuntimeBinderException |
C#
dynamic json = JsonConvert.DeserializeObject(response.Content);
GridView1.DataSource = GetData(json);
GridView1.DataBind();
}
private DataTable GetData(string jsondata)
{
string json = jsondata;
rootObject = JsonConvert.DeserializeObject(json);
List orderDetails = new List();
orderDetails.Add(rootObject.data);
DataTable dataTable = ToDataTable(orderDetails);
return dataTable;
}Below is the response returned
C#
{"status":true,"data":{"id":"16621681","order_id":"29920015","order_number":"890","created":"2022-12-26","edd":"","pickup_date":"","rto_initiate_date":"","delivered_date":"","shipped_date":"","awb_number":"14189990126365","rto_awb":"","courier_id":"3","warehouse_id":"132002","rto_warehouse_id":"132002","status":"cancelled","rto_status":"","shipment_info":"","history":[{"status_code":"PP","location":"CAR\/HUB, Chandigarh, CHANDIGARH","event_time":"2022-12-26 19:37","message":"Pickup Not Done"},{"status_code":"PP","location":"CAR\/HUB, Chandigarh, CHANDIGARH","event_time":"2022-12-26 12:10","message":"Out for Pickup"},{"status_code":"PP","location":"CAR\/HUB, Chandigarh, CHANDIGARH","event_time":"2022-12-26 11:17","message":"Pending"}]}}Thanks

Jignesh KumarRank #91 · 22.9K reputationPosted Dec 27, 2022, 11:12 PM EST
Hi Ramco,
You are passing dynamic object to your function GetData which is expecting string type parameter, you need to convert your response to string as below
dynamic json = JsonConvert.DeserializeObject(response.Content); GridView1.DataSource = GetData(json.ToString()); GridView1.DataBind(); } private DataTable GetData(string jsondata) { rootObject = JsonConvert.DeserializeObject(jsondata); List orderDetails = new List(); orderDetails.Add(rootObject.data); DataTable dataTable = ToDataTable(orderDetails); return dataTable; }Amit MohantyRank #112 · 20K reputationPosted Dec 27, 2022, 11:35 PM EST
Try this
Ajay SinghRank #1,163 · 1.6K reputationPosted Dec 27, 2022, 10:32 PM EST
Hi Ramco, with above code its not clear the exception. May be you cam check your "OrderDetails" class structure should match with "RootObject" class.
Give a try by changing getData method as below
GridView1.DataSource = GetData(json.toString());