microsoftgraph / microsoftgraph/msgraph-sdk-java

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

Ouverte
#2,555 0 commentaires 2 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

status:waiting-for-triage type:bug
Langage dominant
Java
Étoiles
444
Forks
154
Merge moyen
18 h 28 min
PR mergées (30 j)
4

Description

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_

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par reproduire le cas d’un canal partagé avec graphClient.teams().byTeamId(teamId).channels().post(channel) et comparez sa réponse 202 aux réponses 201 pour les canaux standard et privés. Consultez la documentation Microsoft Graph relative à la création de canaux partagés et examinez la gestion des réponses du SDK ; le travail est considéré comme terminé lorsqu’un comportement convenu pour la réponse asynchrone est défini, ou qu’une gestion claire et documentée est fournie si aucune modification de l’API n’est apportée.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
java
Domaine
api
Type d'issue
Bug
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
42/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.