小程序
小游戏
企业微信
微信支付
扫描小程序码分享
我调的时候总是返回{"errcode":41005,"errmsg":"media data missing hint: [icaJuA08392347]"
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
string boundary = "--------------------------" + DateTime.Now.Ticks.ToString("x"); string boundaryH = "------------------------" + DateTime.Now.Ticks.ToString("x"); var formData = new MultipartFormDataContent(boundary); var contentSend = new StreamContent(flstream); contentSend.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = $"\"{contentName}\"", FileName = $"\"{filename}\"" }; contentSend.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); //改写Content-Type contentSend.Headers.Remove("Content-Type"); contentSend.Headers.Add("Content-Type", "multipart/form-data; boundary=" + boundaryH); var boundaryA = formData.Headers.ContentType.Parameters.First(o => o.Name == "boundary");//关键代码 boundaryA.Value = boundaryA.Value.Replace("\"", String.Empty); formData.Add(contentSend); var clientToCall = new HttpClient(/* _proxy */); var token = await _accessTonkenService._GetAccessToken(); var response = await clientToCall.PostAsync($"http://api.weixin.qq.com/cv/ocr/comm?access_token={token.access_token}" , formData);
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
你好,麻烦提供下appid,具体的请求,请求时间
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
string boundary = "--------------------------" + DateTime.Now.Ticks.ToString("x"); string boundaryH = "------------------------" + DateTime.Now.Ticks.ToString("x"); var formData = new MultipartFormDataContent(boundary); var contentSend = new StreamContent(flstream); contentSend.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = $"\"{contentName}\"", FileName = $"\"{filename}\"" }; contentSend.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg"); //改写Content-Type contentSend.Headers.Remove("Content-Type"); contentSend.Headers.Add("Content-Type", "multipart/form-data; boundary=" + boundaryH); var boundaryA = formData.Headers.ContentType.Parameters.First(o => o.Name == "boundary");//关键代码 boundaryA.Value = boundaryA.Value.Replace("\"", String.Empty); formData.Add(contentSend); var clientToCall = new HttpClient(/* _proxy */); var token = await _accessTonkenService._GetAccessToken(); var response = await clientToCall.PostAsync($"http://api.weixin.qq.com/cv/ocr/comm?access_token={token.access_token}" , formData);
你好,麻烦提供下appid,具体的请求,请求时间
.net core web api的类HttpClient生成的boundary如下:
第一个图片
但是微信平台需要的格式是如下:
第二个图片
发出请求前把boundary值的双引号删掉即可