public string doPOST(Uri url, string postData) { Console.WriteLine("POST {0}", url); UTF8Encoding encoding = new UTF8Encoding(); byte[] byteData = encoding.GetBytes(postData); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/json"; request.Accept = "application/json"; request.ContentLength = byteData.Length; if (authHandler != null) { authHandler.SetUpRequest(request); } Stream requestStream = request.GetRequestStream(); requestStream.Write(byteData, 0, byteData.Length); requestStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); string responseStatus = response.StatusDescription; Console.Out.WriteLine("status: {0}", responseStatus); Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); string data = reader.ReadToEnd(); Console.Out.WriteLine(data); reader.Close(); response.Close(); dataStream.Close(); return(data); }