我需要調用從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