Today when you make a project call a third-party WEBAPI, find the GET request unexpectedly using the Fromuri list parameter, Khan ...
Here is a simple way to record the request for a parameter (but it is not recommended to use the Get Fromuri list parameter to define the function of Webapi):
1HttpClient hclient =NewHttpClient (NewMyhttpclienhanlder ());2 3 stringURL ="http://api.test.com/api/pk/index?pkId=2322";4 //var ret = hclient.getasync (URL);5 //var ss = Ret. Result.Content.ReadAsStringAsync (). Result;6 //Console.WriteLine (ss);7 //Console.WriteLine ("\r\n\r\n\r\n****************************************************************\r\n\r\n\r \ n ");8 9list<Long> PIds =Newlist<Long>();TenPids.add (2322); OnePids.add (1824); A //list<keyvaluepair<string, string>> paramlist = new list<keyvaluepair<string, string>> () ; - //Paramlist.add (New keyvaluepair<string, string> ("PkIds", Newtonsoft.Json.JsonConvert.SerializeObject ( (PIDS) )); - the stringParasformat ="pkids[{0}]={1}&"; -StringBuilder paras =NewStringBuilder (); - for(vari =0; i < Pids.count; i++) - { + paras. AppendFormat (Parasformat, I, pids[i]); - } + AURL ="http://api.test.com/api/pk/list?"+ paras. Remove (paras. ToString (). Length-1,1). ToString (); at - //var ret = hclient.postasync (URL, new Formurlencodedcontent (paramlist)); - varRET =hclient.getasync (URL); - varSS =ret. Result.Content.ReadAsStringAsync (). Result; - Console.WriteLine (ss); - inHclient.dispose ();
Webapi GET request Fromuri List parameter Pass