HttpClient _httpClient = new HttpClient();
var postContent = new MultipartFormDataContent();
string boundary = string.Format("--{0}", DateTime.Now.Ticks.ToString("x"));
postContent.Headers.Add("ContentType", $"multipart/form-data, boundary={boundary}");
var requestUri = "url";
var values = new[]
{
new KeyValuePair<string, string>("id","1")
};
foreach (var keyValuePair in values)
{
postContent.Add(new StringContent(keyValuePair.Value),
String.Format("\"{0}\"", keyValuePair.Key));
}
var response = await _httpClient.PostAsync(requestUri, postContent);
//浏览器出参返回入res
if (response.IsSuccessStatusCode)
{
res = response.Content.ReadAsStringAsync().Result;
}
//处理返回JSON数据
var q = JsonConvert.DeserializeObject<MODEL>(res);