var request = new RestRequest("api/Article/List/TotalCount/{CompanyID}", Method.POST) { RequestFormat = DataFormat.Json };
request.AddParameter("CompanyID", CompanyID, ParameterType.UrlSegment);
request.AddBody(filterData);
var response = Client.Execute<GridViewCount>(request);
if (response.Data == null)
throw new Exception(response.ErrorMessage); //Here I am getting Error.
This is the code I have written to call web api using RestSharp.
This code works fine and my Web API code works fine as well. But sometimes I get Error that "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server"
note: this is MVC project.