Rishi Malvi

Rishi Malvi

  • NA
  • 154
  • 3.3k

how to use http client in windows 8 app

Mar 7 2014 3:28 AM

i made an app in windows phone successfully & now i want to make it for windows 8 store app but i stuck on a point where i want to my web service in store app.

I use webclient in WP but i don't know anything about how to access web service in Windows 8 store app. My web service return data in json format i deserialize & store in a variable in WP & i use post method . but how it would be done in Windows 8 store app. what would i use for windows 8 in place of Webclient.

i post my windows phone code

 private void PostData() 
     Uri uri = new Uri(my web service url);
     string data = "device_id=" + val + "&quiz_type=all"; 
       WebClient wc = new WebClient(); 
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded"; 
        wc.UploadStringAsync(uri, data); 
        wc.UploadStringCompleted += wc_UploadComplete;
 }
 public void wc_UploadComplete(object sender, UploadStringCompletedEventArgs e)
var rootObject = JsonConvert.DeserializeObject<RootObject>(e.Result); 
}
You see that i store all the data in rootObject. How these thing can be done in windows 8 app?

Answers (1)