binarywang/WxJava · error · WxErrorException

错误代码:{errorCode}, 错误信息:{errorMsg}

Error message

错误代码:{errorCode}, 错误信息:{errorMsg}

What it means

Error "错误代码:{errorCode}, 错误信息:{errorMsg}" thrown in binarywang/WxJava.

Source

Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaInputStreamUploadRequestExecutor.java:46

  public JoddHttpMediaInputStreamUploadRequestExecutor(RequestHttp<HttpConnectionProvider, ProxyInfo> requestHttp) {
    super(requestHttp);
  }

  @Override
  public WxMediaUploadResult execute(String uri, InputStreamData data, WxType wxType) throws WxErrorException, IOException {
    HttpRequest request = HttpRequest.post(uri);
    if (requestHttp.getRequestHttpProxy() != null) {
      requestHttp.getRequestHttpClient().useProxy(requestHttp.getRequestHttpProxy());
    }
    request.withConnectionProvider(requestHttp.getRequestHttpClient());
    request.form("media", new ByteArrayUploadable(this.toByteArray(data.getInputStream()), data.getFilename()));
    HttpResponse response = request.send();
    response.charset(StandardCharsets.UTF_8.name());

    String responseContent = response.bodyText();
    WxError error = WxError.fromJson(responseContent, wxType);
    if (error.getErrorCode() != 0) {
      throw new WxErrorException(error);
    }
    return WxMediaUploadResult.fromJson(responseContent);
  }

  public byte[] toByteArray(InputStream input) throws IOException {
    try (ByteArrayOutputStream output = new ByteArrayOutputStream()) {
      byte[] buffer = new byte[4096];
      int n = 0;
      while (-1 != (n = input.read(buffer))) {
        output.write(buffer, 0, n);
      }
      return output.toByteArray();
    }
  }
}

View on GitHub (pinned to 1c43293a3c)

Solutions

  1. 根据返回的 errorCode 对照微信接口文档确认具体错误原因并修正请求参数。
  2. 检查 access_token 是否有效、输入流内容是否完整且格式符合要求。

When it happens

Trigger: Thrown at weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/jodd/JoddHttpMediaInputStreamUploadRequestExecutor.java:46 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of binarywang/WxJava@1c43293a3c (2026-08-14). Data as JSON: /api/errors/b6d2531871fdb043. Report an issue: GitHub.