views:

61

answers:

2

Need to have the server make a POST to an API, how do I add POST values to a WebRequest object and how do I send it and get the response (it will be a string) out?

I need to POST TWO values, and sometimes more, I see in these examples where it says string postData = "a string to post"; but how do I let the thing I am POSTing to know that there is multiple form values?

A: 

From the MSDN

http://msdn.microsoft.com/en-us/library/debx8sh9%28VS.80%29.aspx

Take into account that the information must be sent in the format key1=value1&key2=value2

Claudio Redi
thanks, so it's just like a query string, just what I needed, you win
shogun
Yes, basically, so be careful about special characters. You need to encode key and value
Claudio Redi
A: 

A more powerful and flexible example can be found here: C# File Upload with form fields, cookies and headers

Sky Sanders