Monday, March 10, 2014

Making HTTP Post Request

Here is the correct way to send POST using HTTP Client

  var client = new HttpClient();
var postData = new List<KeyValuePair<string, string>>();
postData.Add(new KeyValuePair<string, string>("param1", "value"));
postData.Add(new KeyValuePair<string, string>("param2", "value"));

HttpContent content = new FormUrlEncodedContent(postData);

var response = await client.PostAsync("Post URL", content);

0 comments: