收藏
回答

调用https://api.weixin.qq.com/cv/ocr/返errcode:41005?

Java httpClient Post调用小程序OCR身份证识别,地址:https://api.weixin.qq.com/cv/ocr/idcard?,
返回错误信息:{"errcode":41005,"errmsg":"media data missing hint: [Mu3GOA0088w512] rid: 62e95228-4d4d74bf-24d67d7e"}。


Java 代码示例:
public static String sendHttpPostForm(String httpUrl, MultipartFile file) {

   HttpPost httpPost = new HttpPost(httpUrl);
   try {
      File f = new File("/Users/heqi/Documents/tmp/" + file.getOriginalFilename());
      file.transferTo(f);

      FileBody d = new FileBody(f, ContentType.MULTIPART_FORM_DATA, file.getOriginalFilename());
      HttpEntity httpEntity = MultipartEntityBuilder.create()
            .setCharset(StandardCharsets.UTF_8)
            .setContentType(ContentType.MULTIPART_FORM_DATA)
            .setMode(HttpMultipartMode.BROWSER_COMPATIBLE)
            .addPart("img", d)
            .build();
      httpPost.setEntity(httpEntity);

   } catch (IOException e) {
      e.printStackTrace();
   }

   return sendHttpPost(httpPost);
}

请问这是哪里传错参数了吗?


回答关注问题邀请回答
收藏
登录 后发表内容