I'm experiencing a simple yet annoying issue when using the PostAsJsonAsync<T>(..)
extension method and I can't find information on fixing the following issue anywhere.
My issue is that the Json that gets generated uses PascaCasing
and I require camelCasing
as per the actual standard.
Here's a simple sample that can reproduce the issue (source: http://www.codeproject.com/Articles/611176/Calling-ASP-NET-WebAPI-using-HttpClient):
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:56851/");
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
var user = new Users();
user.FirstName = txtFirst.Text;
user.Company = txtCompany.Text;
user.LastName = txtLas.Text;
user.Email = txtEmail.Text;
user.PhoneNo = txtPhone.Text;
user.Email = txtEmail.Text;
var response = client.PostAsJsonAsync("api/User", user).Result;
if (response.IsSuccessStatusCode)
{
MessageBox.Show("User Added");
txtFirst.Text = "";
txtLas.Text = "";
txtPhone.Text = "";
txtEmail.Text = "";
txtCompany.Text = "";
GetData();
}
else
{
MessageBox.Show("Error Code" +
response.StatusCode + " : Message - " + response.ReasonPhrase);
}