Hi
I am getting error - Using the generic type JsonResult
C#
public JsonResult GetCourier(string token, Int32 origin, Int32 destination)
{
var client = new RestClient("htts://api.nimbuspost.com/v1/courier");
client.Timeout = -1;
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Authorization", "Bearer " + token);
request.AddParameter("origin", origin, ParameterType.RequestBody);
request.AddParameter("destination", destination, ParameterType.RequestBody);
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);
Root root = JsonConvert.DeserializeObject(response.Content);
return Json(new { status = root.status, response = root });
}Thanks

Vishal YelveRank #178 · 13.6K reputationPosted Jan 9, 2023, 8:37 AM EST
try this
IRestResponse response = client.Execute(request); if (response.IsSuccessful) { Root root = JsonConvert.DeserializeObject(response.Content); return Json(new { status = root.status, response = root }); } } else { return new Root(); }