The result is: It is allowed to create team by a Deamon(without a user), but it seems there is a bug in sdk or a bug in the interface of the graph api server.
I test it in my side to create the group with sdk first, it works fine. Below is my code for your reference(if you have no problem with create group, please skip this step):
IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
.Create("<client id>")
.WithTenantId("<tenant id>")
.WithClientSecret("<secret>")
.Build();
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication, "https://graph.microsoft.com/.default");
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var group = new Group
{
Description = "Group with designated owner and members",
DisplayName = "huryNewGroup16",
GroupTypes = new List<String>()
{
"Unified"
},
MailEnabled = true,
MailNickname = "operations201916",
SecurityEnabled = false
};
await graphClient.Groups.Request().AddAsync(group);
After creating the group, I test create a team with the group id. The conclusion which mentioned by Gousia in his answer is correct, but it is not the point. We can not create team without adding at least one member/owner, but even if I add a user as the owner, I still can't create team by sdk. But I can create team in explorer (with auth code flow) and I also can create team in "API Tester" or postman (with Deamon/client_credential flow).
So I continue test the sdk and use fiddler to catch the request from the sdk, the request shown as below:
PUT https://graph.microsoft.com/v1.0/groups/xxxx/team HTTP/1.1
Host: graph.microsoft.com
SdkVersion: Graph-dotnet-1.20.1
FeatureFlag: 0000004F
Cache-Control: no-store, no-cache
Authorization: Bearer xxxxxx
Accept-Encoding: gzip
Content-Type: application/json
Content-Length: 389
{
"memberSettings": {
"allowCreateUpdateChannels": true,
"@odata.type": "microsoft.graph.teamMemberSettings"
},
"messagingSettings": {
"allowUserEditMessages": true,
"allowUserDeleteMessages": true,
"@odata.type": "microsoft.graph.teamMessagingSettings"
},
"funSettings": {
"allowGiphy": true,
"giphyContentRating": "strict",
"@odata.type": "microsoft.graph.teamFunSettings"
},
"@odata.type": "microsoft.graph.team"
}
I also create the team by request in "API Tester" and catch the request by fiddler, the request shown as below:
PUT https://graph.microsoft.com/v1.0/groups/xxxx/team HTTP/1.1
Host: graph.microsoft.com
Connection: keep-alive
Content-Length: 327
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.61
Authorization: Bearer xxxxxx
Content-Type: application/json
Accept: */*
Origin: chrome-extension://aejoelaoggembcahagimdiliamlcdmfm
Sec-Fetch-Site: none
Sec-Fetch-Mode: cors
Sec-Fetch-Dest: empty
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: xxxxx
{
"memberSettings": {
"allowCreateUpdateChannels": true
},
"messagingSettings": {
"allowUserEditMessages": true,
"allowUserDeleteMessages": true
},
"funSettings": {
"allowGiphy": true,
"giphyContentRating": "strict"
}
}
We can find the difference is the first request body has extra @odata.type
, if I remove the @odata.type
fields and request it in "API Tester" again, it can create the team success.
So I think the problem is caused by the @odata.type
in request body when request by sdk. There may be a bug in sdk or a bug in the interface of the graph api server. But for your question about "is it possible that a Deamon without a user to create a team" ? The answer is "yes". But we can't use sdk to do it, we can request it in "API Tester" or postman. Or if you want to do it by code, you can use "HttpClient" to request for access token(with Deamon/client_credential flow) and then request the graph api in your code.