通过MSGraph API创建群组也不会创建一个sharepoint。

问题描述 投票:0回答:1

我通过MSGraph API创建了一个群组,工作正常。创建了一个有所有者、成员等的群组。现在我在MSTeams中手动创建了一个小组。但我不能发送文件,因为没有sharepoint网站!

我试图通过GraphExplorer获取sharepoint链接,但它的反应是404。

因此,我通过GraphExplorer测试了API,并与它创建了一个组。它的工作。有组,和sharepoint网站... ...

这是创建一个新的组的代码。(它是相同的代码,如在MSDocs)

IGraphServiceClient graphApplicationClient = _initGraphServiceApplicationClient();

Group group = new Group();
group.displayName = pGroupDisplayName;
group.description = pGroupDescription;
group.mailEnabled = pMailEnabled;
group.mailNickname = pGroupMailNickname;
group.securityEnabled = pSecurityEnabled;

//Office Group
LinkedList<String> groupTypesList = new LinkedList<>();
groupTypesList.add("Unified");
group.groupTypes = groupTypesList;

group.additionalDataManager().put("[email protected]", _buildMemberJsonArray(pAzureOwnerIds));
pAzureMemberIds.addAll(pAzureOwnerIds);
group.additionalDataManager().put("[email protected]", _buildMemberJsonArray(pAzureMemberIds));

Group groupResponse = graphApplicationClient.groups().buildRequest().post(group);

return groupResponse.id;

如果我在我的Java应用程序中运行这个程序,请求工作正常。但没有创建与它的Sharepoint站点。如果我转到AzurePortal -> Groups,没有指向Sharepoint的Group链接.如果我在Postman或GraphExplorer中用相同的Url、成员、所有者、属性做相同的请求,它在1分钟内创建了一个Sharepoint。

为什么用代码就不行了呢?

这是 azure 中的组,如果我用代码创建它,并手动创建一个团队出来。

Group out of code

还在等待一个Sharepoint

Not able to send files

这是 azure 中的组,如果我用 azure 创建它,并手动创建一个团队,就会出现这样的情况

[Group out of azure[2]

Sharepoint在1分钟内创建。

Able to send files

问候

java microsoft-graph sharepoint-online microsoft-teams
1个回答
0
投票

我用下面的代码测试了这个问题,效果很好。

using Microsoft.Graph;
using Microsoft.Graph.Auth;
using Microsoft.Identity.Client;
using System;
using System.Collections.Generic;

namespace CreategroupTeam
{
    class Updateitem
    {
        static void Main(string[] args)
        {
            string clientId = "e0cxxxx63112"; //e.g. 01e54f9a-81bc-4dee-b15d-e661ae13f382
            string clientSecret = @"1kQTuxxxxx?um05-qZ";
            string tenantID = "8a400dxxxxx872cfeef";

            IConfidentialClientApplication confidentialClientApplication = ConfidentialClientApplicationBuilder
                    .Create(clientId)
                    .WithTenantId(tenantID)
                    .WithClientSecret(clientSecret)
                    .Build();

            ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
            GraphServiceClient graphClient = new GraphServiceClient(authProvider);

            var group = new Group
            {
                Description = "Group with designated owner and members",
                DisplayName = "Operations group",
                GroupTypes = new List<String>()
                {
                    "Unified"
                },
                MailEnabled = true,
                MailNickname = "operations2019",
                SecurityEnabled = false,
                AdditionalData = new Dictionary<string, object>()
                {
                    {
                        "[email protected]",new []{ "https://graph.microsoft.com/v1.0/users/942dd484-cbed-4ed8-b9a8-3f70ef070a4a", "https://graph.microsoft.com/v1.0/users/cb281e9e-7c81-4834-b39d-3ae34f5255e8" }
                    },
                    {
                        "[email protected]",new []{ "https://graph.microsoft.com/v1.0/users/73d72173-732b-4b19-a9c8-b9b0c5e0a567" }
                    }
                }
            };

            var res = graphClient.Groups.Request().AddAsync(group).Result;
            Console.WriteLine(res);

            Console.ReadKey();
        }
    }
}

在创建组后,我在这个组下手动创建了一个团队。所有的工作都很顺利,我能够打开相关的SharePoint站点(它可能需要一些时间来完成初始化,所以事实上我等待了一段时间)。enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.