c# webclient post json example

Example 1: httpclient post c# json

var httpClient = new HttpClient();
  var json = JsonConvert.SerializeObject(ticket);
  var content = new StringContent(json, Encoding.UTF8, "application/json");
  await httpClient.PostAsync("https://address.com", content);

Example 2: webclient c# example post

string URI = "http://www.myurl.com/post.php";
string myParameters = "param1=value1&param2=value2&param3=value3";

using (WebClient wc = new WebClient())
{
    wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
    string HtmlResult = wc.UploadString(URI, myParameters);
}