POST interface formdata parameter transfer template record
var res = ""; HttpClient _httpClient = new HttpClient(); var postContent = new MultipartFormDataContent(); string boundary = ("--{0}", ("x")); ("ContentType", $"multipart/form-data, boundary={boundary}"); var requestUri = "url"; var values = new[] { new KeyValuePair<string, string>("id","1") }; foreach (var keyValuePair in values) { (new StringContent(), ("\"{0}\"", )); } var response = await _httpClient.PostAsync(requestUri, postContent); //The browser returns to res if () { res = ().Result; } // Processing to return JSON data var q = <MODEL>(res);
It will be convenient to view and record in the future
C# simulates formdata submission parameters
public string GetFormdata(Dictionary<string, string> dic,string ticks) { string Info = ""; string Head = ("----------------------------{0}", ticks); string Foot = ("----------------------------{0}--", ticks); foreach (var item in dic){ Info += ("{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}\r\n", Head, , ); } Info += Foot; return Info; }
string Ticks = (); string Paramter = GetFormdata(dic, Ticks); string Html = ""; using (HttpHelper http = new HttpHelper()){ HttpItem item = new HttpItem(); = "/api//createSaleOrder"; = "post"; ("token", Token); = ("multipart/form-data; boundary=--------------------------{0}", Ticks); = .UTF8; = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Trident/4.0; EmbeddedWB 14.52 from: / EmbeddedWB 14.52; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E; Tablet PC 2.0; TCO_20150304085044)"; = ; = Paramter; HttpResult result = (item); Html = ; }
The above is personal experience. I hope you can give you a reference and I hope you can support me more.