Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

互联企业的消息推送接口返回字段类型和官网api不一致 #2148

Closed
pingtiandasheng opened this issue Jun 8, 2021 · 9 comments

Comments

@pingtiandasheng
Copy link

简要描述

接口返回字段类型和企业微信官网api不一致

模块版本情况

  • WxJava 模块名: weixin-java-cp 消息推送
  • me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult
  • WxJava 版本号:4.1.0

详细描述

@SerializedName("invaliduser")
private String invalidUser;
@SerializedName("invalidparty")
private String invalidParty;
@SerializedName("invalidtag")
private String invalidTag;

字段类型不一致,json转换会报错

日志

2021-06-08 14:55:33.452 [http-nio-8080-exec-2] INFO c.m.a.config.exception.handler.MyExceptionHandler - java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 43 path $.invaliduser
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 43 path $.invaliduser
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
at com.google.gson.Gson.fromJson(Gson.java:932)
at com.google.gson.Gson.fromJson(Gson.java:897)
at com.google.gson.Gson.fromJson(Gson.java:846)
at com.google.gson.Gson.fromJson(Gson.java:817)
at me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult.fromJson(WxCpMessageSendResult.java:30)
at me.chanjar.weixin.cp.api.impl.WxCpMessageServiceImpl.sendLinkedCorpMessage(WxCpMessageServiceImpl.java:49)
at com.mychery.awesomeproject.service.impl.WxCommonServiceImpl.sendLinkedCorpMessage(WxCommonServiceImpl.java:51)
at com.mychery.awesomeproject.service.impl.PushMessageServiceImpl.pushMessage(PushMessageServiceImpl.java:88)
at com.mychery.awesomeproject.service.impl.PushMessageServiceImpl.PCPushMessage(PushMessageServiceImpl.java:55)
at com.mychery.awesomeproject.controller.PushMessageController.messagePush(PushMessageController.java:44)
at com.mychery.awesomeproject.controller.PushMessageController$$FastClassBySpringCGLIB$$98daf70f.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)

@binarywang
Copy link
Owner

请发出原始报文,看样子是由于出现了数组

@binarywang
Copy link
Owner

如果我没看错,官方文档是这样写的:

 {
   "errcode" : 0,
   "errmsg" : "ok",
   "invaliduser" : "userid1|userid2",
   "invalidparty" : "partyid1|partyid2",
   "invalidtag": "tagid1|tagid2"
 }

@pingtiandasheng
Copy link
Author

请发出原始报文,看样子是由于出现了数组

是的,官网的返回实例现在是这样的
{
"errcode" : 0,
"errmsg" : "ok",
"invaliduser" : ["userid1","userid2","CorpId1/userid1","CorpId2/userid2"], // 不区分大小写,返回的列表都统一转为小写
"invalidparty" : ["partyid1","partyid2","LinkedId1/partyid1","LinkedId2/partyid2"],
"invalidtag":["tagid1","tagid2"]
}

@pingtiandasheng
Copy link
Author

如果我没看错,官方文档是这样写的:

 {
   "errcode" : 0,
   "errmsg" : "ok",
   "invaliduser" : "userid1|userid2",
   "invalidparty" : "partyid1|partyid2",
   "invalidtag": "tagid1|tagid2"
 }

我看到的官网咋是这样的
{
"errcode" : 0,
"errmsg" : "ok",
"invaliduser" : ["userid1","userid2","CorpId1/userid1","CorpId2/userid2"], // 不区分大小写,返回的列表都统一转为小写
"invalidparty" : ["partyid1","partyid2","LinkedId1/partyid1","LinkedId2/partyid2"],
"invalidtag":["tagid1","tagid2"]
}
api地址
https://work.weixin.qq.com/api/doc/90000/90135/90250

@binarywang
Copy link
Owner

你用的是互联企业的消息推送?看来两种消息返回结构不一致导致的

@pingtiandasheng
Copy link
Author

你用的是互联企业的消息推送?看来两种消息返回结构不一致导致的

嗯嗯是的

@pingtiandasheng
Copy link
Author

期待大神们丰富一下这一块

@binarywang
Copy link
Owner

期待不如自己马上行动,提交PR,这是目前最快的方法,你如果要等大佬行动,那可要且等了

@binarywang binarywang reopened this Jun 11, 2021
@binarywang binarywang changed the title 接口返回字段类型和企业微信官网api不一致 互联企业的消息推送接口返回字段类型和企业微信官网api不一致 Jun 11, 2021
@binarywang binarywang changed the title 互联企业的消息推送接口返回字段类型和企业微信官网api不一致 互联企业的消息推送接口返回字段类型和官网api不一致 Jun 11, 2021
ParkerJX pushed a commit to ParkerJX/WxJava that referenced this issue Jun 25, 2021
* 'develop' of github.com:Wechat-Group/WxJava:
  ⬆️ Bump jetty-server from 9.4.38.v20210224 to 9.4.41.v20210516 (binarywang#2164)
  🆕 binarywang#2163 【开放平台】增加查询小程序可回退版本的接口
  🐛 binarywang#2148 【企业微信】修复互联企业消息推送接口返回字段问题
  🆕 binarywang#2161 【公众号】微信推送消息类增加群发接口事件相关字段
  🆕 binarywang#2150 【企业微信】补充完善部分客户联系接口,以及服务商模式外部联系人openid转换接口
  🎨 binarywang#2155 【企业微信】发送新客户欢迎语接口增加对视频类型的支持,同时修复结构不正确的问题
@stale
Copy link

stale bot commented Aug 10, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants