I'm using HttpClient in .net 4.5 application to post custom object to Web API service.
Code:
public async Task<HttpStatusCode> Run(Customer customer)
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://someaddress.net/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.PostAsJsonAsync("api/TestApi", customer)
}
}
Is there a way to get size of this request before calling PostAsJsonAsync?
Thanks.