我需要调用从Web服务的方法,所以我写了这个代码:如何将参数添加到WebRequest中?
private string urlPath = "http://xxx.xxx.xxx/manager/";
string request = urlPath + "index.php/org/get_org_form";
WebRequest webRequest = WebRequest.Create(request);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.
webRequest.ContentLength = 0;
WebResponse webResponse = webRequest.GetResponse();
但这种方法需要一些参数,如下:
发表数据:
_username:'API USER', // api authentication username
_password:'API PASSWORD', // api authentication password
如何将这些参数添加到此Webrequest中?
在此先感谢。
@Omid一个数字,表示系统应如何长时间后放弃等待。 – RyanfaeScotland 2015-02-13 11:32:43
与@ CoderHawk的回答相比似乎有些复杂。 – Kehlan 2015-05-28 18:44:39
老话题但是..什么是“常量”? – 2016-08-02 23:16:55