收藏
回答

调用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);
}

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


回答关注问题邀请回答
收藏

2 个回答

  • Mr.Zhao
    Mr.Zhao
    2022-08-03
    setCharset setContentType setMode 去掉就能调通了
    
    2022-08-03
    有用
    回复
  • 小茵儿
    小茵儿
    发表于移动端
    2022-08-03
    ggggggggghg
    2022-08-03
    有用
    回复
登录 后发表内容