我试图将HttpPostedFileBase发布到远程webApi。
public bool CreateClaimAttachmentCustomerDoc(ClaimAttachmentSimple attachment, HttpPostedFileBase hpf)
{
string jsonStrAttchment = JsonConvert.SerializeObject(attachment);
string jsonHpf = JsonConvert.SerializeObject(hpf);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(
ConfigurationManager.AppSettings["ApiBaseUrl"] + "claim/CreateClaimAttachmentCustomerDoc?attachment=" + jsonStrAttchment + "&hpf=" + jsonHpf);
request.Method = "POST";
request.ContentType = "application/json";
WebResponse webResponse = request.GetResponse();
using (Stream webStream = webResponse.GetResponseStream())
{
if (webStream != null)
{
using (StreamReader responseReader = new StreamReader(webStream))
{
responseReader.ReadToEnd();
return true;
}
}
}
return false;
}
收到以下错误。
Newtonsoft.Json.JsonSerializationException:'从中获取值时出错 ' ReadTimeout' on' System.Web.HttpInputStream'。' InvalidOperationException:此流不支持超时。