【问题标题】:Create a group via MSGraph API doesn't create a sharepoint too通过 MSGraph API 创建组也不会创建共享点
【发布时间】:2020-04-24 10:28:59
【问题描述】:

我通过 MSGraph API 创建了一个组。 它工作得很好。组是由所有者、成员等创建的。现在我在 MSTeams 中手动创建了一个团队。但是我无法发送文件,因为没有共享点站点!

我尝试通过 GraphExplorer 获取共享点链接,但它响应 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("owners@odata.bind", _buildMemberJsonArray(pAzureOwnerIds));
pAzureMemberIds.addAll(pAzureOwnerIds);
group.additionalDataManager().put("members@odata.bind", _buildMemberJsonArray(pAzureMemberIds));

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

return groupResponse.id;

如果我在我的 Java 应用程序中运行它,请求工作正常。但是没有使用它创建的 Sharepoint 站点。如果我转到 AzurePortal -> 组,则没有指向共享点的组链接。 如果我在 Postman 或 GraphExplorer 中使用相同的 Url、成员、所有者、属性执行相同的请求,它会在 1 分钟内创建一个共享点。

为什么它不能与代码一起使用???

如果我用代码创建它并手动创建一个团队,这就是天蓝色的组

仍在等待共享点

如果我用 azure 创建它并手动创建一个团队,这就是 azure 中的组

[

在不到 1 分钟的时间内创建共享点..

最好的问候!

【问题讨论】:

  • 能否用您正在尝试的代码更新您的问题,以便我们查看?
  • 我做到了。如果我这样做,我不确定你是否会收到通知(我是新手)。所以我在这里提到你@Trinetra-MSFT。请看一下。
  • 谢谢,让我看看,我会尽快回复你

标签: java microsoft-graph-api sharepoint-online microsoft-teams


【解决方案1】:

我用以下代码测试了这个问题,它运行良好。

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>()
                {
                    {
                        "members@odata.bind",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" }
                    },
                    {
                        "owners@odata.bind",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 网站(可能需要一些时间才能完成初始化,所以实际上我等待了一段时间)。

【讨论】:

  • 您是否在我的代码中看到任何错误,或者您是否在做与我不同的事情?我再次尝试了我的代码,但没有共享点站点...该组已创建。从中创建了一个团队。没有共享点。无法发送文件...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-04-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多