{"record":{"id":"604848acc88da368","repo":"binarywang/WxJava","slug":"errorcode-errormsg-604848","errorCode":null,"errorMessage":"错误代码：{errorCode}, 错误信息：{errorMsg}","messagePattern":"错误代码：(.+?), 错误信息：(.+?)","errorType":"exception","errorClass":"WxErrorException","httpStatus":null,"severity":"error","filePath":"weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java","lineNumber":51,"sourceCode":"              .addFormDataPart(\"upload_type\", this.uploadType)\n              .addFormDataPart(\"media\", file.getName(), RequestBody.create(MediaType.parse(\"application/octet-stream\"), file))\n              .build();\n    }\n    else {\n      body = new MultipartBody.Builder()\n              .setType(MediaType.parse(\"multipart/form-data\"))\n              .addFormDataPart(\"resp_type\", this.respType)\n              .addFormDataPart(\"upload_type\", this.uploadType)\n              .addFormDataPart(\"img_url\", this.imgUrl)\n              .build();\n    }\n    Request request = new Request.Builder().url(uri).post(body).build();\n\n    Response response = requestHttp.getRequestHttpClient().newCall(request).execute();\n    String responseContent = response.body().string();\n    WxError error = WxError.fromJson(responseContent, wxType);\n    if (error.getErrorCode() != 0) {\n      throw new WxErrorException(error);\n    }\n    log.info(\"responseContent: {}\", responseContent);\n\n    return WxMinishopImageUploadCustomizeResult.fromJson(responseContent);\n  }\n\n}\n","sourceCodeStart":33,"sourceCodeEnd":59,"githubUrl":"https://github.com/binarywang/WxJava/blob/1c43293a3c2c9d7e91304b6d037fb017f680d0c6/weixin-java-common/src/main/java/me/chanjar/weixin/common/util/http/okhttp/OkHttpMinishopMediaUploadRequestCustomizeExecutor.java#L33-L59","documentation":"Thrown by the OkHttp minishop (small-store) customized image-upload executor when WeChat returns a non-zero errcode. Unlike the plain media executor, the body carries form fields resp_type, upload_type and img_url (image-by-URL upload) instead of a file part. The response body is parsed into WxError and rethrown as WxErrorException when errorCode != 0.","triggerScenarios":"Calling the minishop customized image upload with an invalid/expired access_token, an img_url that is unreachable or not HTTPS, an unsupported resp_type/upload_type value, or when WeChat cannot fetch the supplied image URL.","commonSituations":"img_url pointing to a non-public or HTTP-only CDN; access_token expired; wrong resp_type (e.g. not matching the expected response container); upstream WeChat gateway returning a non-JSON error body that deserializes to a non-zero code.","solutions":["Read e.getError().getErrorCode()/getErrorMsg() for the precise WeChat code and act on it.","Ensure img_url is publicly reachable over HTTPS and returns a supported image content-type.","Verify resp_type/upload_type are among the values documented for the minishop image API.","Make sure the access_token is valid and refreshed."],"exampleFix":"// before\nWxMinishopImageUploadCustomizeResult r = service.execute(url, info);\n// after\ntry {\n  WxMinishopImageUploadCustomizeResult r = service.execute(url, info);\n} catch (WxErrorException e) {\n  log.error(\"minishop customize upload errcode={} msg={}\",\n    e.getError().getErrorCode(), e.getError().getErrorMsg());\n  throw e;\n}","handlingStrategy":"validation","validationCode":"String imgUrl = info.getImgUrl();\nif (imgUrl == null || !imgUrl.startsWith(\"https://\")) {\n  throw new IllegalArgumentException(\"img_url must be a public HTTPS url\");\n}\nSet<String> ok = Set.of(\"image/png\", \"image/jpeg\");\nif (!ok.contains(info.getRespType())) {\n  throw new IllegalArgumentException(\"unsupported resp_type\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  WxMinishopImageUploadCustomizeResult r = service.execute(uri, info);\n} catch (WxErrorException e) {\n  log.error(\"errcode={} msg={}\", e.getError().getErrorCode(), e.getError().getErrorMsg());\n  throw e;\n}","preventionTips":["Ensure img_url is HTTPS and publicly fetchable by WeChat.","Validate resp_type/upload_type against the minishop docs.","Refresh access_token before the call."],"tags":["weixin-api","okhttp","minishop","media-upload","network"],"backgroundTag":null,"analyzedSha":"1c43293a3c2c9d7e91304b6d037fb017f680d0c6","analyzedAt":"2026-08-14T02:29:11.060Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}