可以在RestSharp中的POST请求中添加Json Body和文件吗?
request.RequestFormat = DataFormat.Json;
request.AddFile("file", Writer,Guid.NewGuid() + ".pdf","application/pdf");
request.AddBody(model);
var response = (RestResponse)client.Execute(request);
当我尝试使用上面的代码发送请求时,我遇到了错误。
错误消息:写入开始后无法设置此属性。
栈跟踪
at System.Net.HttpWebRequest.set_ContentLength(Int64 value)at RestSharp.Http.WriteRequestBody(HttpWebRequest webRequest)at RestSharp.Http.PostPutInternal(String method)at RestSharp.Http.AsPost(String httpMethod)at RestSharp.RestClient.DoExecuteAsPost(IHttp http,String方法)at RestSharp.RestClient.Execute(IRestRequest请求,字符串httpMethod, Func`3 getResponse)