TransWikia.com

Microsoft Teams Graph API - Invalid bind property name owners in request

Stack Overflow Asked on December 5, 2020

I’m currently having major issues with creating teams from the Graph API. I was initially trying to create teams based on groups, however I have found out today that you can now create a team without creating a group first then waiting 15 minutes to then create the team from the following link. This would make things considerably simpler.

https://docs.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0

I am using the Microsoft.Graph SDK (v3.12.0 released 26th Aug) so replicated the http call using the SDK as follows.

        var team = new Team
        {
            DisplayName = "My Group Name",
            Description = "My Group Description",
            AdditionalData = new Dictionary<string, object>()
            {
                {"[email protected]", "https://graph.microsoft.com/v1.0/teamsTemplates('educationClass')"},
                {"[email protected]", $"["https://graph.microsoft.com/v1.0/users('{usersGuid}')"]"}
            },
        };

        var response = await _graphClient.Teams
            .Request()
            .AddAsync(team);

The code above gives a:

[16:14:01 ERR] An unhandled exception has occurred while executing the request.
Status Code: BadRequest
Microsoft.Graph.ServiceException: Code: BadRequest
Message: Invalid bind property name owners in request.

If I remove the line

{"[email protected]", $"["https://graph.microsoft.com/v1.0/users('{usersGuid}')"]"}

from the code I get the following:

ErrorMessage : {"errors":[{"message":"A team owner must be provided when creating a team in application context."}]

Any advice would be greatly appreciated.

Thanks,
Nick

One Answer

In v1.0 the owners relationship is not currently present, so you have to use the beta endpoint. POST: https://graph.microsoft.com/beta/teams

with the following body format

{ "[email protected]":"https://graph.microsoft.com/beta/teamsTemplates('standard')", "displayName":"Test Team", "description":"Test description", "[email protected]":["https://graph.microsoft.com/v1.0/users/{user guid}"] }

Note: the user guid should also be bare, i.e without the brackets and quotes in your example.

Correct answer by David on December 5, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP