0

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

  • can you paste the code ? Looks like its a bit different from what is there in the answer – Gautam Sheth Mar 27 '18 at 11:06
0

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.

  • thanks alot var createModernSite = context.CreateSiteAsync(modernteamSiteInfo).GetAwaiter().GetResult(); // this is working fine again thanks Sir :) – Hassan Nawaz Mar 27 '18 at 12:27
  • Can we set the owner of team site ? – Hassan Nawaz Mar 27 '18 at 13:15
  • Yes, we can. Can you ask it as another question? I will attempt to answer there. I can't answer it in the comments as its a bit long and also out of scope for the current question :) – Gautam Sheth Mar 28 '18 at 6:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.