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);
您好!我想从asp.net core webapi 调用ocr.printedText,又没有参考?我调的时候总是返回{"errcode":41005,"errmsg":"media data missing hint: [icaJuA08392347]"
2020-07-17