Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when creating a new group connected site collection? #1567

Open
1 task done
LarsThomasNilsson opened this issue Oct 30, 2024 · 2 comments
Open
1 task done

Bug when creating a new group connected site collection? #1567

LarsThomasNilsson opened this issue Oct 30, 2024 · 2 comments
Labels
area:admin 📜 Admin library related question Further information is requested

Comments

@LarsThomasNilsson
Copy link

LarsThomasNilsson commented Oct 30, 2024

Category

  • Bug

Error when creating new Sharepoint group enabled site collection (first issue reported, hope I did everything right)

Steps to reproduce

When running the follwong code I get a graph exception, "{HttpResponseCode: 400Code: Request_BadRequestMessage: The value of 'odata.bind' property annotation is an empty array. The 'odata.bind' property annotation must have a non-empty array as its value.ClientRequestId

Code:
using (var pnpContext = await contextFactory.CreateAsync("SiteToWorkWith"))
{
var teamSiteToCreate = new TeamSiteOptions("mynewsite", "My new site")
{
Description = "My site description",
Visibility = PnP.Core.Model.Security.GroupVisibility.Public,
Owners = new string[] { "[email protected]" }
};

     SiteCreationOptions siteCreationOptions = new SiteCreationOptions()
     {
         UsingApplicationPermissions = true
     };
     using (var newSiteContext = await pnpContext.GetSiteCollectionManager().CreateSiteCollectionAsync(teamSiteToCreate, siteCreationOptions))
     {
         // Do work on the created site collection via the newSiteContext
     };

}

Expected behavior

A new group connected site collection to be created

Environment details (development & target environment)

SDK version**: 1.14

  • OS: Windows 11

  • SDK used in:Console App

  • Framework: .NET 8.0

  • Tooling: Visual Studio 2022

  • Additional details: The more context you can provide, the easier it is (and therefore quicker) to help.

Additional context

My Entra ID app has application permssions on Microsoft.Graph
Group.Create
Group.ReadWrite.All
Sites.Fullcontrol.All

My Entra ID app has application permssions on SharePoint:
Sites.Fullcontrol.All

It works to create a non group enabled site collection:
var teamsite = new TeamSiteWithoutGroupOptions(new Uri(siteUrl), title.ToString())
{
Description = description.ToString(),
Language = PnP.Core.Admin.Model.SharePoint.Language.Swedish,
Owner = owner.ToString(),
Title = title.ToString(),
SensitivityLabelId = new Guid(azureFunctionSettings.SensitivityLabelIdSite)
};

//Get the context to the new site and perform additional config
using (var newSiteContext = await pnpContext.GetSiteCollectionManager().CreateSiteCollectionAsync(teamsiteBDO))
{

};

Thanks for all contributions to this SDK! It's great. Sharing is caring.

@jansenbe jansenbe added question Further information is requested area:admin 📜 Admin library related labels Nov 18, 2024
@jansenbe
Copy link
Contributor

@LarsThomasNilsson : I just tried to reproduce your issue by running on our test cases (https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core.Admin.Test/SharePoint/SiteCreationTests.cs#L940-L1036) and this worked fine using app-only permissions. Can you check that code and verify yours, if you still get an error please post the they payload you're sending to the server

@adrian-jakobsson
Copy link

Hi! I am the developer that took over @LarsThomasNilsson and the problem was on our end, our app had insufficient permissions for User.Read.All and Directory.Read.All in the Microsoft Graph-permissions in Azure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:admin 📜 Admin library related question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants