I have to send POST request to web service with multiple parameters where one of them has byte[] type. But I dont know how to pass byte[] parameter. Does anybody know? Also, I would like to know how to send byte[] array in GET requests. Any help will be appreciated!
using (var client = new WebClient())
{
var values = new NameValueCollection();
values["thing1"] = "hello";
values["thing2"] = "world"; // how to pass byte[] here?
var response = client.UploadValues("http://www.example.com/recepticle.aspx", values);
var responseString = Encoding.Default.GetString(response);
}
or another variant with HttpClient:
private static readonly HttpClient client = new HttpClient();
var values = new Dictionary<string, string>
{
{ "thing1", "hello" },
{ "thing2", "world" } // how to pass byte[] here?
};
var content = new FormUrlEncodedContent(values);
var response = await client.PostAsync("http://www.example.com/recepticle.aspx", content);
var responseString = await response.Content.ReadAsStringAsync();