C# Post form-data 上传

1.首先先从NuGet下载包

 

 

 

 

 2.方法

public  string PostData(string UrlAdd, string inputData){
            string str = "";
            try
            {
                HttpClient client = new HttpClient();
                var postContent = new MultipartFormDataContent();
                postContent.Add(new StringContent(inputData), "inputData");
                HttpResponseMessage response = client.PostAsync(Url + UrlAdd, postContent).Result;
                str = response.Content.ReadAsStringAsync().Result;
            }
            catch (Exception ex)
            {
             
                return ex.ToString();
            }
           
            return str;
 }

3.PostMan调用

 

posted @ 2021-07-16 17:37  朱志  阅读(726)  评论(0编辑  收藏  举报