When I run the following code the RESTful web service receiving the request has an empty body (content length = 0) and I don't know why?
If I run Fiddler whilst debugging the request executes as expected and the server receives the body, I guess I'm not configuing something for the request any ideas?
var request = (HttpWebRequest)WebRequest.Create(uri);
request.ContentType = "text/xml";
request.Method = "POST";
request.CookieContainer = new CookieContainer();
request.CookieContainer.Add(uri, new Cookie("SSOToken", HttpUtility.UrlEncode(SsoToken)));
request.ContentLength = data.Length;
request.BeginGetRequestStream(ar1 =>
{
var byteArray = Encoding.UTF8.GetBytes(data);
var stream = request.EndGetRequestStream(ar1);
stream.Write(byteArray, 0, data.Length);
stream.Close();
request.BeginGetResponse(ar2 => HandleSearchCompleted(ar2, request, action), state);
}, state);