microsoftgraph / microsoftgraph/msgraph-sdk-java

`channels().post()` returns `null` when creating a shared channel (`membershipType: shared`)

未关闭
#2,555 0 条评论 2 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

status:waiting-for-triage type:bug
主要语言
Java
星标
444
派生
154
平均合并
18 小时 28 分钟
30 天内合并 PR
4

描述

Describe the bug

When creating a channel with membershipType set to ChannelMembershipType.Shared, the graphClient.teams().byTeamId(teamId).channels().post(channel) method returns null instead of a Channel object.
This works correctly for standard and private channel types, which return the expected Channel object.

Root cause analysis

According to the Microsoft Graph API documentation (Example 5 — Create a shared channel), creating a shared channel returns an HTTP 202 Accepted with a Location header pointing to a teamsAsyncOperation, whereas standard/private channels return a 201 Created with the Channel object in the response body.

The SDK's .post() method appears to only handle the 201 Created case, deserializing the response body into a Channel object. When it receives a 202 Accepted (with no Channel in the body), it returns null without providing access to the response headers or the async operation.

This is the same issue reported in the .NET SDK: microsoftgraph/msgraph-sdk-dotnet#1728

Expected behavior

One of the following:

  • Preferred: The SDK should detect the 202 Accepted response, follow the Location header, poll the teamsAsyncOperation until completion, and return the resulting Channel object — providing a consistent developer experience across all channel types.

  • Alternative: The SDK should return a wrapper type (e.g., ChannelPostResponse) that can represent either a Channel (for 201) or a TeamsAsyncOperation (for 202), along with the Location/Content-Location headers.

  • Minimum: The documentation should clearly state that .post() returns null for shared channels, and provide a documented pattern to retrieve the channel using NativeResponseHandler (or equivalent in Java).

How to reproduce
ChannelMembershipType type = ChannelMembershipType.Shared;

Channel channel = new Channel();
channel.setOdataType("#Microsoft.Graph.channel");
channel.setMembershipType(type);
channel.setDisplayName("My Shared Channel");
channel.setDescription("Test shared channel creation");

LinkedList<ConversationMember> members = new LinkedList<>();
AadUserConversationMember conversationMember = new AadUserConversationMember();
conversationMember.setRoles(List.of("owner"));
HashMap<String, Object> additionalData = new HashMap<>();
additionalData.put("user@odata.bind",
    "https://graph.microsoft.com/v1.0/users('" + ownerId + "')");
conversationMember.setAdditionalData(additionalData);
members.add(conversationMember);
channel.setMembers(members);

// This returns null for shared channels, but works for standard/private
Channel result = graphClient.teams().byTeamId(teamId).channels().post(channel);

System.out.println(result); // null
SDK Version

6.62.0

Latest version known to work for scenario above?

6.62.0

Known Workarounds

None

Debug output
Click to expand log ```
</details>


### Configuration

_No response_

### Other information

_No response_

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先在 graphClient.teams().byTeamId(teamId).channels().post(channel) 重现共享频道的情况,并将其 202 响应与标准频道和专用频道的 201 响应进行比较。阅读 Microsoft Graph 的共享频道创建文档,并检查 SDK 的响应处理;完成条件是就异步响应达成一致的行为,或者在不进行 API 更改的情况下提供明确的文档化处理方式。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api
Issue 类型
缺陷
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。