C#使用HTTPClient来提交数据,以下是代码实现的功能是向指定的Url使用Json格式提交数据。注意:在.Net Core中如何正确的使用HTTPClient,可以参考:https://lebang2020.cn/details/210120apxzwjkr.html

 

 HttpClient httpClient = new HttpClient();
            string url1 = @"https://lebbang2020.cn/api/StudentInfo/InfoByVehicleVIN";
            var postArgs = new { VIN = "00152F3B1895355561317EAEAFD778843C864520" };
            var response = await httpClient.PostAsync(url1, new StringContent(JsonConvert.SerializeObject(postArgs), Encoding.UTF8, "application/json"));
            if (response.IsSuccessStatusCode)
            {
                var resStr = await response.Content.ReadAsStringAsync();
                ApiResModel res = JsonConvert.DeserializeObject<ApiResModel>(resStr);
                

            }

lebang.cn