Anton Kasianchuk
Anton Kasianchuk

Reputation: 1217

How can I add additional parameters to multipart POST request?

I use HttpWebRequest to upload file on the server. But I also want to send some parameters (I mean name-value pairs)

Upvotes: 0

Views: 746

Answers (2)

ST3
ST3

Reputation: 8946

you can try this:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("some site");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
byte[] data = "some data";
request.ContentLength = data.Length;
using (Stream stream = request.GetRequestStream())
{
    stream.Write(data, 0, data.Length);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Upvotes: 0

Mike Van Vertloo
Mike Van Vertloo

Reputation: 192

You can add them to the query string. They'll be available on the server, regardless of whether the HTTP method is POST or GET.

Upvotes: 1

Related Questions