title: Http Post Get Response Error for Windows Phone 8
body: <p>I am reposting this second question from my original post (<a href="https://stackoverflow.com/questions/14698879/http-post-for-windows-phone-8">Http Post for Windows Phone 8</a>) because my primary question was alreayd answered. </p>
  
  <p>This is my updated code with the help of @Hunter McMillen.. I am now trying to get a responseCallback from the server.  The problem is the <code>GetResponseCallback =&gt; (HttpWebResponse)httpWebRequest.EndGetResponse(GetResponseCallback)</code> line in the second using statement, it is displaying </p>
  
  <pre><code>An exception of type 'System.Net.WebException' occurred in System.Windows.ni.dll but was not handled in user code
  
  If there is a handler for this exception, the program may be safely continued.
  </code></pre>
  
  <p>This error occured before when I was using the first example.  Does anyone know how to solve this?</p>
  
  <pre><code>  private static async void HttpPostData(){
              string url = "http://www.mytunnel.com/api/purchases";
              HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
              httpWebRequest.ContentType = "text/plain";
              //httpWebRequest.ContentType = "application/x-www-form-urlencoded";
              httpWebRequest.AllowWriteStreamBuffering = true;
              httpWebRequest.Method = "POST";
              //httpWebRequest.ContentLength = jsonAsBytes.Length;
  
          try{
              using (var stream = await Task.Factory.FromAsync&lt;Stream&gt;(httpWebRequest.BeginGetRequestStream, httpWebRequest.EndGetRequestStream, null))
              {
                  byte[] jsonAsBytes = Encoding.UTF8.GetBytes("{ \"data\" : \"json\" }");
                  await stream.WriteAsync(jsonAsBytes, 0, jsonAsBytes.Length);
              }
          }
          catch (Exception e) { Debug.WriteLine(e.Message); }
  
          httpWebRequest.BeginGetResponse(new AsyncCallback(ReadWebRequestCallback), httpWebRequest);
      }
  
      private static void ReadWebRequestCallback(IAsyncResult callbackResult)
      { 
          HttpWebRequest myRequest = callbackResult.AsyncState as HttpWebRequest;
  
          try
          {
              HttpWebResponse response = myRequest.EndGetResponse(callbackResult) as HttpWebResponse;
              using (StreamReader sr = new StreamReader(response.GetResponseStream()))
              {
                  String s = sr.ReadToEnd();
                  System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =&gt; { MessageBox.Show(s); });
              }
          }
          catch (WebException webExcp)
          {
              System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =&gt; { MessageBox.Show(webExcp.ToString()); });
          }
      }
  </code></pre>