收藏
回答

调用WxMaService获取二维码报错"errcode":40097,"怎么处理?

核心代码
public GenerateQrcodeRespVO generateQrcode(SocialWxQrcodeReqDTO reqVO) {
    try {
        GenerateQrcodeRespVO qrcodeReqDTO = new GenerateQrcodeRespVO();
        // 核心修改:生成12位随机字母数字串(可改为10/16位,建议8-16位)
        String businessId = RandomUtil.randomString(20);
        qrcodeReqDTO.setBusinessId(businessId);
        //先保存到redis,redis键值
        stringRedisTemplate.opsForValue().set("businessSign:signatureGenerateId:" + businessId, businessId, 10, TimeUnit.MINUTES);
        reqVO.setScene(businessId);
        reqVO.setPath("pagesMain/views/businessSign/index");
        reqVO.setCheckPath(false);
        byte[] qrcodeByte = socialClientService.getWxaQrcode(reqVO);
        qrcodeReqDTO.setQrcodeByte(qrcodeByte);
        return qrcodeReqDTO;
    } catch (Exception e) {
        log.error("[getWxQrcode][reqVO({}) 获得小程序码失败]", reqVO, e);
        throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR);
    }
}
public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) {
    WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
    try {
        return service.getQrcodeService().createWxaCodeUnlimitBytes(
                ObjUtil.defaultIfEmpty(reqVO.getScene(), SocialWxQrcodeReqDTO.SCENE),
                reqVO.getPath(),
                ObjUtil.defaultIfNull(reqVO.getCheckPath(), SocialWxQrcodeReqDTO.CHECK_PATH),
                envVersion,
                ObjUtil.defaultIfNull(reqVO.getWidth(), SocialWxQrcodeReqDTO.WIDTH),
                ObjUtil.defaultIfNull(reqVO.getAutoColor(), SocialWxQrcodeReqDTO.AUTO_COLOR),
                null,
                ObjUtil.defaultIfNull(reqVO.getHyaline(), SocialWxQrcodeReqDTO.HYALINE));
    } catch (WxErrorException e) {
        log.error("[getWxQrcode][reqVO({}) 获得小程序码失败]", reqVO, e);
        throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_QRCODE_ERROR);
    }
}
报错信息:
me.chanjar.weixin.common.error.WxErrorException: 错误代码:40097, 错误信息:参数错误,微信原始报文:{"errcode":40097,"errmsg":"invalid args rid: 695f0568-5de47e63-3eef7ff9"}
回答关注问题邀请回答
收藏

2 个回答

  • Mr.Zhao
    Mr.Zhao
    01-08

    postman截个图吧

    01-08
    有用
    回复
  • 智能回答 智能回答 本次回答由AI生成
    01-08
    有用
    回复 2
    • 残夜
      残夜
      01-08
      请求信息:
      750504 【请求地址】: https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=99_oae69LvLYHoih1Si_JyEeooTUY-b2f3U4HMId0TNLVbiGq7c-GMhl9vWUroaG84QgQ3MzhyqHooZnkBwKwTe6tri88HjsS9Qw5wUjwRpXFxsSGN20R3mZgv7nq8SSXaAIANNS
      750505 【请求参数】:WxaCodeUnlimit(scene=70545877011c4a968d58d3d6bf13868e, page=pagesMain/views/businessSign/index, checkPath=false, envVersion=formal, width=430, autoColor=true, isHyaline=true, lineColor=null)
      750506 【错误信息】:错误代码:40097, 错误信息:参数错误,微信原始报文:{"errcode":40097,"errmsg":"invalid args rid: 695f0568-5de47e63-3eef7ff9"}
      750507 2026-01-08 09:16:24.633 | ^[[1;31mERROR 1301759^[[0;39m | ^[[1;33mhttp-nio-48086-exec-6 [TID: N/A]^[[0;39m ^[[1;32mc.s.m.s.s.s.SocialClientServiceImpl ^[[0;39m | [getWxQrcode][reqVO(SocialWxQrcodeReqDTO(scene=70545877011c4a968d58d3d6bf13868e, path=pagesMain/v iews/businessSign/index, width=null, autoColor=null, checkPath=false, hyaline=null)) 获得小程序码失败]
      01-08
      回复
    • 智能回答 智能回答 本次回答由AI生成
      01-08回复残夜
登录 后发表内容