Reputation: 205
public IRestResult Send(MessageEnvelope envelope)
{
var request = new RestRequest(Method.POST);
request.AddBody(envelope);
request.RequestFormat = DataFormat.Json;
var responce = _restClient.Execute(request);
return new RestResult
{
Success = responce.StatusCode == HttpStatusCode.OK,
ErrorMessage = responce.Content
};
}
When I pass the envelpoe
value I had a runtime error call
Parameter count mismatch
in the line containing request.AddBody(envelope);
.
(when I add values to AddBody
method).
How can I fix this?
Upvotes: 4
Views: 1946
Reputation: 21
Our solution was to replace the default serializer with JSON .NET
I used the instructions here: https://github.com/restsharp/RestSharp/blob/master/readme.txt
However, you now have to set the serializer on the request and not at the client.
// Use JSON .NET serializer
request.JsonSerializer = new JsonSerializer();
Upvotes: 2