首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >通过sharepoint创建组不会同时创建MSGraph

通过sharepoint创建组不会同时创建MSGraph
EN

Stack Overflow用户
提问于 2020-04-24 18:28:59
回答 1查看 95关注 0票数 0

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

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

所以我通过GraphExplorer测试了这个应用程序接口,并用它创建了一个组。它起作用了。这是组,还有sharepoint站点...

这是用于创建新组的代码。(它与MSDocs中的代码相同)

代码语言:javascript
复制
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 sharepoint组,则没有指向->的组链接。如果我在Postman或GraphExplorer中使用相同的网址、成员、所有者、属性执行相同的请求,它会在1分钟内创建一个sharepoint。

为什么它不能与代码一起工作?

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

仍在等待sharepoint

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

[

Sharepoint在1分钟内创建完成..

诚挚的问候!

EN

回答 1

Stack Overflow用户

发布于 2020-04-28 15:06:50

我用以下代码测试了这个问题,它工作得很好。

代码语言:javascript
复制
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站点(可能需要一些时间才能完成初始化,所以实际上我会等待一段时间)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61406267

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档