SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following code iterates through the pages in our wiki then tries to add a new one. It adds fine but the PageLayout is changed to null after the page is added. Is there any way to set the PageLayout on a new page using web service calls? I'm trying to avoid using the Microsoft.Sharepoint library.

        ServiceReference1.HomeDataContext home = new HomeDataContext(new Uri("http://utah:82/_vti_bin/ListData.svc"));            
        home.Credentials = System.Net.CredentialCache.DefaultCredentials;

        foreach (var Page in home.Pages)
            this.TxtActivity.AppendText("Page: " + Page.Name + Environment.NewLine);
            int acnt = 0;

        PagesItem page = new PagesItem();
        page.ApprovalStatus = "0";
        page.Name = "TestCodePage1.aspx";
        page.ContentType = "Enterprise Wiki Page";            
        page.ContentTypeID = "0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39004C1F8B46085B4D22B1CDC3DE08CFFB9C0004D854AA15019B4CBC2BCC51663D50F6";
        page.Path = "/Pages";            
        page.Title = "Testy Code Pagey1";
        page.PageLayout = @"http://utah:82/_catalogs/masterpage/EnterpriseWiki.aspx, Basic Page";


        home.SetSaveStream(page, new MemoryStream(Encoding.UTF8.GetBytes("Test code testy. ")), false, page.ContentType, page.Path + @"\" + page.Name);
share|improve this question

There are at least two ways you can use a Web service to create a new wiki page.

The first is to use the Copy.CopyIntoItems service to make a copy of the raw ASPX file. Using this approach, you will actually be able to modify the contents of the file "on the fly" before saving back into SharePoint.

The second is to use the Lists.AddWikiPage service to add a new page to a wiki library. Using this approach, you only have to specify the contents of the wiki and do not have to worry about all the other ASPX file content.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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