Stack Exchange
Restsharp- Method.POST is not working
I have tried all possible scenarios as per RestSharp.org documentation but no luck!
I have ASP.Net Web API here is the POST resource
[Route("/api/saveperson/{name}/{fathername}")]    
public void Post([FromBody]CustomObject customObject, string name, string fatherName)
{
      //customObject is null
}

RestSharp request:
public void SomeAPIRequest()
{
 var baseUrl = "someurl from config";
var client = new RestClient(baseUrl);
var request = new RestRequest("/api/saverperson/{name}/{fathername}",Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(myObject);  //This object is perfectly serialized in json
request.AddParameter("name","Gaurav",ParameterType.UrlSegment);
request.AddParameter("fathername","Lt. Sh. Ramkrishan",ParameterType.UrlSegment);

var response= client.Execute(request);

}

With above code Parameter posted in Body is always null. 
When, I made following call, Parameter posted in Body is having value but others are null
public void SomeAPIRequest()
{
 var baseUrl = "someurl from config";
var client = new RestClient(baseUrl);
var request = new RestRequest("/api/saverperson/{name}/{fathername}",Method.POST);
request.RequestFormat = DataFormat.Json;
request.AddBody(myObject);  //This object is perfectly serialized in json
request.AddUrlSegment("name","Gaurav");
request.AddUrlSegment("fathername","Lt. Sh. Ramkrishan");

var response= client.Execute(request);

}

Any help will be mostly welcomed!

It has been also posted here: https://github.com/restsharp/RestSharp/issues/622

I found the solution. Answering my own question so, that folks who are facing similar issue can find the solution.
Just need to do the request as:
request.AddParameter("Application/Json", myObject, ParameterType.RequestBody);

Following is the complete snippet:
public void SomeAPIRequest()
{
   var baseUrl = "someurl from config";
   var client = new RestClient(baseUrl);
   var request = new RestRequest("/api/saverperson/{name}/{fathername}",Method.POST);
   request.RequestFormat = DataFormat.Json;
   request.AddParameter("Application/Json", myObject, ParameterType.RequestBody);
   request.AddUrlSegment("name","Gaurav");
   request.AddUrlSegment("fathername","Lt. Sh. Ramkrishan");

   var response= client.Execute(request);

}

Above code, resolved my issue.
