I would recommend you to use WebClient
. Here is the example:
using (var wb = new WebClient())
{
var uri = new Uri("http://yourhost/api/GetPanels");
// Your headers, off course if you need it
wb.Headers.Add(HttpRequestHeader.Cookie, "whatEver=5");
// data - data you need to pass in POST request
var response = wb.UploadValues(uri, "POST", data);
}
ADDED
To convert your data to nameValue collection you can use next:
NameValueCollection formFields = new NameValueCollection();
data.GetType().GetProperties()
.ToList()
.ForEach(pi => formFields.Add(pi.Name, pi.GetValue(data, null).ToString()));
Then just use the formFields
in POST request.