fudiwei / DotNetCore.SKIT.FlurlHttpClient.Wechat

可能是全网最完整的 C# 版微信 SDK,封装全部已知的微信 OpenAPI,包含微信公众平台(订阅号+服务号+小程序+小游戏+小商店+视频号)、微信开放平台、微信商户平台(微信支付+微企付)、企业微信、微信广告平台、微信智能对话开放平台等模块,可跨平台。持续随官方更新,欢迎 Star/Fork/PR。QQ 交流群 875580418【满】、930461548【满】、611974621。
https://github.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient
MIT License
1.47k stars 285 forks source link

[BUG] 企微获取部门成员详情接口的gender类型定义错误 #135

Closed dabai closed 4 months ago

dabai commented 4 months ago

关于问题的简单描述 类型定义错误。 企微获取部门成员详情接口中,性别gender接口返回的是string,与CgibinUserListResponse.cs定义的int不一致,会导致System.Text.Json.Serialization在反序列化时异常。 REF: https://developer.work.weixin.qq.com/document/path/90201


与问题相关的源代码 SKIT.FlurlHttpClient.Wechat.Work\Models\CgibinUser\CgibinUserListResponse.cs

/// <summary>
/// 获取或设置性别。
/// </summary>
[Newtonsoft.Json.JsonProperty("gender")]
[System.Text.Json.Serialization.JsonPropertyName("gender")]
public int Gender { get; set; }

异常堆栈或异常原因

The JSON value could not be converted to System.Int32. Path: $.userlist[0].gender | LineNumber: 0 | BytePositionInLine: XXXX.


发生问题的运行环境

请在此填写以下几项内容:

  1. 操作系统:如:Windows 11
  2. .NET 版本:.NET 6.0
  3. 使用的模块及版本:SKIT.FlurlHttpClient.Wechat.Work 3.2.1
fudiwei commented 4 months ago

可以先指定 JSON 序列化器为 Newtonsoft.Json 规避此错误,System.Text.Json 对标准化要求比较高。后面我会修复此问题。

fudiwei commented 4 months ago

已修复。将随下一版本 release,敬请留意。