Question

when I create team site using the code from the following URL: Create Modern Sites in SharePoint Online using CSOM

it show the error in the given image.

enter image description here

Était-ce utile?

La solution

I see that you are using this code in a console application.

It looks like your code is executing before the team site is created which causes the 404 error.

You need to wait for the site to be created using the Wait or GetAwaiter method as below in a console application:

TeamSiteCollectionCreationInformation modernteamSiteInfo = new TeamSiteCollectionCreationInformation
{
    Description = "Test modern teamsite description",
    DisplayName = "Test Modern Team Site",
    Alias = "TestModernTeamSite",
    IsPublic = true,
    //Classification="IT"                       
};

var createModernSite = context.CreateSiteAsync(modernteamSiteInfo).GetAwaiter().GetResult();
// further code once the site is created

or

context.CreateSiteAsync(modernteamSiteInfo).Wait();

Use this in the console and write your code after the Wait.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top