1
Answer

how to use http client in windows 8 app

Rishi Malvi

Rishi Malvi

10y
2k
1

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)