代码示例,换上自己的就可以用了
HttpClient _http = new HttpClient();
string url = "请求的API";
// 这是value
IDictionary<string, string> Data = new Dictionary<string, string>();
Data.Add("prescriptionstarttime", "2022-02-12 08:30:00");
Data.Add("prescriptionendtime", "2022-03-13 08:30:00");
// 这里是key value
IDictionary<string, string> sendData =new Dictionary<string, string>();
sendData.Add("dhyjson", JsonConvert.SerializeObject(Data));
// 表单格式 请求数据
HttpContent content = new FormUrlEncodedContent(sendData);
HttpResponseMessage response = await _http.PostAsync(url, content);
response.EnsureSuccessStatusCode();//用来抛异常的
//返回数据
string responseBody = await response.Content.ReadAsStringAsync();