I'm a .NET newbie and I'm playing with the WebClient class to consume a simple rest service. What I need to do is post a file to the service with some parameters in QueryString. The WebClient provides the QueryString NameValueCollection which is designed exactly to pass parameters in a QueryString and it works JUST on Get methods so in my case the QueryString collection doesn't fit because while uploading the file the WebClient is actually doing a POST. So I'm stuck. Any ideas? thank you in advance.
Asked
Active
Viewed 2,058 times
1 Answers
1
You can pass the query string parameters in the address
parameter for UploadData:
client.UploadData("http://my.server.com/service?id=1&name=foo", myData);

carlosfigueira
- 85,035
- 14
- 131
- 171
-
Actually... this works but it turns out that I needed to send the file just like an html form no raw data so I had to use HttpWebRequest. Anyway thanks! – user711643 Jun 26 '11 at 21:45