Search code examples
c#microsoft-graph-apimicrosoft-teamsmicrosoft-graph-teams

Cannot create multiple private channels in a team


I am trying to create a private team with several private channels through the Graph API. The first request creates a channel with no problem, but the second request and any further requests to create a channel for that team fails for me, whether it is a private or public.
I have tried using both the Microsoft.Graph and Microsoft.Graph.Beta Nuget packages, and also requests through Postman, along with using both the beta and v1.0 endpoint.
I am sending the following request body to https://graph.microsoft.com/beta/teams/{teamid}/channels

{
    "description": "channelDesc352242415",
    "displayName": "channelName45",
    "membershipType": "private",
    "@odata.type": "microsoft.graph.channel",
    "members": [
        {
            "roles": [
                "owner"
            ],
            "@odata.type": "microsoft.graph.aadUserConversationMember",
            "[email protected]": "https://graph.microsoft.com/beta/users('{userid}')"
        }
    ]
}

and I end up receiving

{
  "error": {
    "code": "BadRequest",
    "message": "Failed to execute Skype backend request GetThreadsS2SRequest.",
    "innerError": {
      "date": "2020-11-16T15:18:01",
      "request-id": "e0824bab-3e5b-41f7-b65c-d915dc8c3d4a",
      "client-request-id": "e0824bab-3e5b-41f7-b65c-d915dc8c3d4a"
    }
  }
}

I have tried it through three different tenants, where one is my own free organisation, and the other two belongs to our customers. It works without any issue for one of our customer tenants, but not for my own tenant and the other customer. For my own tenant I have tried giving my application all permissions but it does not fix the problem. I am using application permissions and not delegated permissions.
About three weeks ago it worked without any issues for all three tenants.
Does anyone have an idea to what it could be, or have seen similar behaviour?


Solution

  • I tested this and came to a conclusion:

    When you use this api to create a private channel on behalf of the user for the first time, it will succeed, but if you call the api again, it will return a 400 error. The error message is the same as yours. A team id can only create a private channel once.

    At the same time, I checked some documents, and I found that this is a common error, so I think the error is still under repair. See: here.