.net Core 调用api里的post方法之 form传值

            HttpClient client = new HttpClient();
            client.Timeout = new TimeSpan(0, 45, 0);
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("multipart/form-data"));
            MultipartFormDataContent content = new MultipartFormDataContent();
            content.Add(new StringContent("1"), "pageIndex");
            content.Add(new StringContent("25"), "pageSize");
            
            var result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;

 

posted @ 2020-12-08 23:04  星星c#  阅读(1587)  评论(0编辑  收藏  举报