0

I am using the SharePoint 2016 C# CSOM SDK to create a subsite in a site collection (code below). However, I get this error:

at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream) at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()

The code does work and the site gets created, but I don't know what the error is?

Code:

                ClientContext context = new ClientContext(sp2016url);
                WebCreationInformation creation = new WebCreationInformation();             
                creation.WebTemplate = "{9D2F0ED0-8EAC-4E22-83D5-B44E5F2AED85}#legnewtemplate";
                creation.Url = GetIDFromKey(legdata.file_reference); 

                creation.Title = "Site";
                creation.Language = 1033;
                creation.UseSamePermissionsAsParentSite = true;
                Web newWeb = context.Web.Webs.Add(creation);

                NetworkCredential cred = new NetworkCredential(@"xxxxx", "xxxxx", "xxxx");
                CredentialCache cache = new CredentialCache();
                cache.Add(new Uri(sp2016url), "NTLM", cred);

                context.Credentials = cache;
                // Retrieve the new web information. 
                context.Load(newWeb, w => w.Title);
                context.ExecuteQuery();
0

Please try this Code:

                ClientContext context = new ClientContext(sp2016url);
                NetworkCredential cred = new NetworkCredential(@"xxxxx", "xxxxx", "xxxx");
                CredentialCache cache = new CredentialCache();
                cache.Add(new Uri(sp2016url), "NTLM", cred);
                context.Credentials = cache;

                WebCreationInformation creation = new WebCreationInformation();             
                creation.WebTemplate = "{9D2F0ED0-8EAC-4E22-83D5-B44E5F2AED85}#legnewtemplate";
                creation.Url = GetIDFromKey(legdata.file_reference);                    

                creation.Title = "Site";
                creation.Language = 1033;
                creation.UseSamePermissionsAsParentSite = true;
                Web newWeb = context.Web.Webs.Add(creation);
                context.ExecuteQuery();

                // Retrieve the new web information. 
                context.Load(newWeb, w => w.Title);
                context.ExecuteQuery();

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.