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调用