convert object to httpcontent csharp

Code Example - convert object to httpcontent csharp

                
                        //from string
ByteArrayContent content = new StringContent(jData);

//from any other object
string myContent = JsonConvert.SerializeObject(data);
ByteArrayContent content = new StringContent(jBalances);

content.Headers.ContentType = new MediaTypeHeaderValue(MediaTypeNames.Application.Json);

var result = await client.PostAsync("", content).ConfigureAwait(false);