how to use post method in webclient RRS feed

  • Question

  • Hi

    I am developing a windows phone8 app,

    I need to post some data to a web service call, how can i do that with "WebClient".

    I need to send a large date, like "StackTrace" and "Exception" ,,,,,,,

    Can anybody help me.

    Thank you.


    Tuesday, April 2, 2013 7:25 AM

All replies

  • You can use WebApi and WebClient to post the data.

    Check below article:



    Tuesday, April 2, 2013 8:59 AM
  • Hi Sumit,

    I have tried the above Example ,

    it doesn't show any error while running, but it doesn't serves the purpose.

    here my code

     public void sendCrashReport()
     Uri uri = new Uri((, UriKind.Absolute);
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append("time" + currTime);
     string jsonData = JsonConvert.SerializeObject(stringBuilder.ToString());
                    WebClient webClient = new WebClient();
                    webClient.Headers["Content-type"] = "application/json";
                    webClient.Encoding = Encoding.UTF8;
                    webClient.UploadStringCompleted += new UploadStringCompletedEventHandler(webClient_UploadStringCompleted);
                    webClient.UploadStringAsync(uri, "POST", jsonData);           
      private void webClient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)

    Actually the service call is for crash report, and it will send the mail to developers, I checked the url in poster it's working fine, and sends the mail.

    But when hit that service call from my app code, nothing happens, no mail is sending at all,

    The uploadStringCompleted event firing, but it shows this error,

    InnerException = {System.Net.WebException: The remote server returned an error: NotFound.

    StackTrace = "   at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()\r\n   at System.Net.UploadStringCompletedEventArgs.get_Result()"

    do you know why is this happening,


    Tuesday, April 2, 2013 2:16 PM
  • Can your phone/device connect to  Use IE to navigate to a page there and see if you get a 404 error, or "this site isn't available"

    Darin R.

    Tuesday, April 2, 2013 9:16 PM