HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
webRequest.Method = "POST";
webRequest.ContentType = "application/json";
webRequest.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
webRequest.ServicePoint.Expect100Continue = false;
if (headers != null)
webRequest.Headers.Add(headers);
using (Stream stream = webRequest.GetRequestStream())
using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
writer.Write(json.ToString());
JsonClass jsonAnswer;
using (WebResponse response = webRequest.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream, Encoding.UTF8))
{
Json parser = new Json();
jsonAnswer = (JsonClass)parser.Parse(reader.ReadToEnd());
}