HttpClient 发送multipart/form-data请求

添加body参数:
var formdata = new MultipartFormDataContent();
formdata.Add(new StringContent("2312"), "userId");
formdata.Add(new StringContent("1"), "payamount");
formdata.Add(new StringContent("小王"), "name");
替换Boundary内的双引号:
var boundaryValue = formdata.Headers.ContentType.Parameters.Single(p => p.Name == "boundary");
boundaryValue.Value = boundaryValue.Value.Replace(""", String.Empty);

上一篇:form表单动态设置enctype不生效问题


下一篇:接口测试之post常见数据提交方式