Reputation: 345
We are creating a team group (with the beta Graph API) and we want the emailaddress to contain another value than the value that's based on what's provided in displayName
.
While searching through the documentation it seems that this is possible by providing a value for mailNickname
in AdditionalData
(https://learn.microsoft.com/en-us/graph/teams-create-group-and-team).
So I implemented that. Unfortunately the mailaddress and the alias were still like [email protected]
instead of [email protected]
.
var graphApiServiceClient = new GraphServiceClient(this.authenticationProvider)
{
BaseUrl = "https://graph.microsoft.com/beta"
};
var owner = "valueForOwner";
var teamTemplate = teamTemplateType == TeamTemplateType.Staff
? "educationStaff"
: "educationClass";
var team = new Team
{
AdditionalData = new Dictionary<string, object>
{
{ "[email protected]", $"https://graph.microsoft.com/beta/teamsTemplates('{teamTemplate}')" },
{ "[email protected]", new[]{$"https://graph.microsoft.com/beta/users('{owner}')"}},
{ "displayName", "TestGroup" },
{ "description", "This is a testgroup" },
{ "mailNickname", "TestMailNickname" }
}
};
await graphApiServiceClient.Teams.Request().AddAsync(team);
The MailNickname
does change when I update the MailNickname
property afterwards with an update request like await graphApiServiceClient.Groups[objectId].Request().UpdateAsync(new Group { MailNickname = mailNickname});
.
This is confirmed with a graphApiServiceClient.Groups[objectId].Request().GetAsync()
Unfortunately it still shows [email protected]
as the alias in the admin at https://admin.microsoft.com/AdminPortal/Home#/groups.
But, updating the value like this doesn't work for the Mail
property because it states it's readonly in the update request.
Does anyone know what I am doing wrong in my original create/add request?
Plus does anyone know why the old alias value is still shown instead of the updated alias at https://admin.microsoft.com/AdminPortal/Home#/groups?
Upvotes: 0
Views: 1408
Reputation: 56
It looks like you are using an EDU tenant, since you are referencing the particular templates.
I have tested this previously, and the method suggested above will not work with the "EducationClass" template.
The way I got it to work was:
$Teamdata =
'{
"displayName":"' + $newteamName + '",
"description":"' + $newteamName + '",
"[email protected]": "https://graph.microsoft.com/v1.0/teamsTemplates(\u0027educationClass\u0027)",
"hideFromOutlookClients": "true",
"hideFromAddressLists": "true",
"members":[
{
"@odata.type":"#microsoft.graph.aadUserConversationMember",
"roles":[
"owner"
],
"[email protected]":"'+ $DefaultOwnerURL + '"
}
]
}'
$Body_SetGroupSDSSettings =
'{
"mailNickname": "' + $newteamMailNickname + '"
}'
It isn't perfect, but it is the best way I could find to do this.
Upvotes: 1
Reputation: 11
This is possible by creating a group via the Graph api first and then using the group ID to create a team for this group.
Create the group via "https://graph.microsoft.com/v1.0/groups".
{
"displayName": "TestGroup",
"mailNickname": "TestMailNickname",
"mailEnabled": true,
"securityEnabled": false,
"description": "This is a testgroup",
"groupTypes": [
"Unified"
],
"[email protected]": [
"https://graph.microsoft.com/v1.0/users/OWNEDID"
]
}
Once the group has been made it'll output an ID which you'll then use to create a team via "https://graph.microsoft.com/v1.0/groups/YOURIDHERE/team"
Body would look something like;
{
"memberSettings": {
"allowCreateUpdateChannels": false,
"allowAddRemoveApps": false,
"allowCreateUpdateRemoveTabs": false,
"allowCreateUpdateRemoveConnectors": false
}
}
Upvotes: 1