private static byte[] CreateBody(RawPostData postData) { var stream = new MemoryStream(); using (var writer = new BinaryWriter(stream)) { writer.Write(Encoding.GetBytes(postData.Value)); } return(stream.ToArray()); }
private static void WriteRequestBody(WebRequest request, string contentType, RawPostData postData) { request.ContentType = contentType; var body = CreateBody(postData); request.ContentLength = body.Length; using (var writer = new BinaryWriter(request.GetRequestStream())) { writer.Write(body); } }