Marek Kyzivát
Marek Kyzivát

Reputation: 343

Unable to create a Team programmatically

I have successfully created Office 365 Group, added members and owners and now I am trying to provision a Team for this group. How am I supposed to provision it using MS Graph in .NET Console App?

I tried the following code but I am not getting my Team.

var team = new Team
{
    GuestSettings = new TeamGuestSettings
    {
        AllowCreateUpdateChannels = false,
        AllowDeleteChannels = false
    }
};

await graphServiceClient.Groups[groupID].Team.Request().CreateAsync(team);

Response from the above code

Message: No HTTP resource was found that matches the request URI 'https://api.teams.skype.com/v1.0/groups('da87fc59-403b-4b0f-973f-f812d41143aa')/team'.

Inner error

Error Screenshot

Edit: I am using latest NUGET package for MS Graph extensions.

Edit 2: Tried to do following instead.

await graphServiceClient.Groups[groupID].Team.Request().PutAsync(team);

Got this:

Code: UnauthorizedAccess Message: Failed to execute Aad backend request GetTenantSubscribedSkusRequest. Request Url: https://graph.windows.net/dc7b2a82-XXXX-XXXX-XXXX-46122279d033/subscribedSkus?api-version=1.6, Request Method: GET, Response Status Code: Unauthorized, Response Headers: ocp-aad-diagnostics-server-name: HmmXXX+7Su9HNJVjwqsmVjPsrXXXXXXXX/iNwuI3H74= request-id: 9257706c-XXXX-XXXX-XXXX-bbf33b98da7d client-request-id: f263695b-XXXX-XXXX-XXXX-9fdf185fXXXX Strict-Transport-Security: max-age=31536000; includeSubDomains Date: Wed, 19 Jun 2019 13:20:18 GMT

Any suggestions?

Upvotes: 2

Views: 1947

Answers (5)

Shan
Shan

Reputation: 81

Microsoft document says

If the group was created less than 15 minutes ago, it's possible for the Create team call to fail with a 404 error code due to replication delays. The recommended pattern is to retry the Create team call three times, with a 10 second delay between calls.

I faced this issue and after the retry logic as suggested above it works fine all the time

Upvotes: 1

Marek Kyzivát
Marek Kyzivát

Reputation: 343

It was a service bug. Works now.

Link to service bug on GitHub

Upvotes: 0

Ryan Schouten
Ryan Schouten

Reputation: 1

I noticed I have the same problem with application permissions. The one thing I have found that will unblock the code to work again is to create a team through the Graph Explorer and then I am good for a couple days.

Then the error comes back again and I create another team through the explorer and I can start creating like before. This tells me it is not a code problem but an issue on the Teams graph connection somewhere.

Upvotes: 0

Jeremy Thake MSFT
Jeremy Thake MSFT

Reputation: 2138

Can you confirm that the group actually gets created? "No HTTP resource was found that matches the request URI" often means that the graphServiceClient.Groups[groupID] doesn't work. Which is likely around permissions.

Upvotes: 0

baywet
baywet

Reputation: 5342

  • Make sure you are using a Delegated authentication context (a user must be signed in) with the permission Group.ReadWrite.All
  • Make sure you have consented to the application permissions (from the API permissions screen of the application registration, you'll find a Grant Consent button all the way down)
  • Use the PutAsync method (today, as you mentioned, you must create the Office 365 group first and then enable Teams)

Upvotes: 0

Related Questions