//实例代码:
1.post请求
private string GetImageXY(string imgbyte) { string result3 = string.Empty; try { string requestUri = "";//请求的url HttpClient httpClient = new HttpClient(); //参数实例 p1=v1&p2=v2 string str = "imgbase64=" + imgbyte; var content = new StringContent(str, Encoding.UTF8, "application/x-www-form-urlencoded"); HttpResponseMessage result = httpClient.PostAsync(requestUri, content).Result; string result2 = result.Content.ReadAsStringAsync().Result; result3 = result2; } catch (Exception ex) { result3 = "error"; } return result3; }
2.Get请求
//有时间再来补充 |