Skip to content

企业微信调用创建用户时,添加 自定义字段 失败 #1738

Description

@dddd-dot

版本

  <dependency>
                <groupId>com.github.binarywang</groupId>
                <artifactId>weixin-java-cp</artifactId>
                <version>3.9.0</version>
            </dependency>
  1. wxCpUserService.create(wxCpUser); 打印 wxCpUser json:
{"gender":"FEMALE","name":"xxx","externalAttrs":[],"departIds":[331],"isLeaderInDept":[0],"position":"xxxx","userId":"xxxx","mainDepartment":"331","email":"xxx@xxx.com","extAttrs":[{"textValue":"A00263","name":"工号","type":0}]}
  1. 转换json导致 字段缺失
public void create(WxCpUser user) throws WxErrorException {
       String url = this.mainService.getWxCpConfigStorage().getApiUrl("/cgi-bin/user/create");
       this.mainService.post(url, user.toJson());
   }

中的 user.toJson()

{"userid":"xxx","name":"xxxx","department":[331],"position":"xxxx","gender":"2","email":"xxx@xxxx.com","is_leader_in_dept":[0],"main_department":"331","extattr":{"attrs":[{"text":{"value":"A00263"}}]},"external_profile":{}}

转换后 extattr 中 attrs 字段缺失了name 导致添加自定义字段失败。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions