Followup on my question Getting null values when deserializing a list using RestSharp
I have another problem now. I need to call POST and the json body should look like this:
{"email": {"evstatus": "processed"}}
My code look like this
class Email
{
public string Evexpire { get; set; }
public string Evfields { get; set; }
public string Evsysseq { get; set; }
public string Evtime { get; set; }
public string Evtype { get; set; }
public string Evstatus { get; set; }
}
var client = new RestClient("xxx");
client.Authenticator = new HttpBasicAuthenticator("xx", "x");
var request = new RestRequest("xxxx/action/processed", Method.POST);
request.RequestFormat = DataFormat.Json;
request.RootElement = "email";
request.AddJsonBody(new Email { Evstatus = "processed" } );
But I receive this error:
"StatusCode: BadRequest, Content-Type: application/json;charset=utf-8, Content-Length: 0)"
When I look at the request in the debugger I see this in the parameter list which apart from the fields with null values do not look like what I need.
{application/json={"Evexpire":null,"Evfields":null,"Evsysseq":null,"Evtime":null,"Evtype":null,"Evstatus":"processed"}}
What should I change/add to get this to work? (I got this request to work in SoapUI)