Like a lot of us I'm green when it comes to SharePoint development. I've been tasked with moving MediaWiki content over to a SharePoint Enterprise wiki. At this time I do not have access to the server the SP is on and have to do this all client side. I can successfully GET information or even change a publishing page's content but I can't create a new wiki page with Microsoft.Sharepoint.Client (I tried via ListItem etc).

 ClientContext context = new ClientContext("http://<site>/");
 ListItem LItem = pagesList.GetItemById(8);
 LItem["PublishingPageContent"] = "This is my new value!!";


The above code worked great! Then I tried:

  ListItemCreationInformation newPage = new ListItemCreationInformation();
  ListItem newpageitem = pagesList.AddItem(newPage);
  newpageitem["Title"] = "OtherCompany";
  newpageitem["PublishingPageContent"] = "Info for Other Company";


this didn't work so great. :-(

Does anyone know if this is even possible to do this client side?


How to create a Wiki page via CSOM

/// <summary>
/// Create Wiki page
/// </summary>
/// <param name="pagesList">Wiki Pages list</param>
/// <param name="pageName">Wiki page name</param>
/// <param name="pageContent"></param>
public static ListItem CreateWikiPage(List pagesList, string pageName, string pageContent)
    const string templateRedirectionPageMarkup = "<%@ Page Inherits=\"Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c\" %> <%@ Reference VirtualPath=\"~TemplatePageUrl\" %> <%@ Reference VirtualPath=\"~masterurl/custom.master\" %>";
    var pageInfo = new FileCreationInformation
                Url = pageName,
                Content = Encoding.UTF8.GetBytes(templateRedirectionPageMarkup),
                Overwrite = true

    var ctx = pagesList.Context;
    var wikiFile = pagesList.RootFolder.Files.Add(pageInfo);

    var wikiItem = wikiFile.ListItemAllFields;
    wikiItem["PublishingPageContent"] = pageContent;
    wikiItem["PublishingPageLayout"] = "/_catalogs/masterpage/EnterpriseWiki.aspx, Basic Page";
    return wikiItem;


using (var ctx = new ClientContext(url))
    var pagesList = ctx.Web.Lists.GetByTitle("Pages"); 
    var wikiItem = CreateWikiPage(pagesList,"SharePoint Overview.aspx","Welcome to the SharePoint!");
  • I am no longer working on this project, nor was I when this answer was published. If people find this helpful in answering the original question please upvote it and I'll mark it the answer.
    – TWhite
    Dec 8 '15 at 22:55

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.