5

I'm using the SharePoint 2013 Client Library and am trying to generate new wiki articles.

I'm able to connect, retrieve the web, find the list, but I can't add items. I feel like I need to be using Microsoft.SharePoint.Client.Publishing, since I am really trying to create a publishing page, but I'm not sure how to go about this.

ClientContext context = new ClientContext("http://mosspractice.example.com/sites/DocDemo/");
List list = context.Web.Lists.GetByTitle("Documentation");

context.Load(list);
context.ExecuteQuery();

ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem newItem = list.AddItem(itemCreateInfo);
newItem["Title"] = "Peter API Test 1";
newItem["Page Content"] = "Hello World!";
newItem.Update(); 

context.ExecuteQuery(); //errors saying Title is not a valid column name...

Any guidance would be greatly appreciated.

3 Answers 3

3

I found a working example at. https://web.archive.org/web/20150710164136/http://spdevlab.com/2013/03/28/creating-wiki-web-part-and-publishing-pages-via-csom-in-sharepoint-2010/. This example worked on the first try without issue.

3
  • Hehe, thanks Peter. SP2010 is quite challenging to crack. SP2013 is much better, however some of the areas are still not covered. I'd also would recommend to check out SPMeta2 library to get more insights and code samples.
    – user656
    Jun 14, 2013 at 9:46
  • the link is dead, that answer should probably be updated
    – baywet
    Dec 20, 2017 at 16:25
  • @baywet, found the content on internet archive. Link updated.
    – Peter
    Dec 21, 2017 at 0:03
1

Well the quick stuff first:

A Wiki Page is NOT a publishing page, so you are probably not trying to create a publishing page..

Secondly:

"Page Content" is not an internal name of a SharePoint field / column. They do not contain white space, the actual internal name is "WikiField"

Not sure why it tells you that "Title" is invalid though! But I would guess it is because a field with that internal name does not exist in the list "Documentation"

5
  • Do I need to specify the content type so that it will know which columns are available?
    – Peter
    Jun 13, 2013 at 13:47
  • Could be, sorry but I'm not an expert on Client object model. I just spotted some errors when glancing through your code that I wanted to point out before you had to spot them yourself! Jun 13, 2013 at 13:49
  • Oh, but look what I found! social.technet.microsoft.com/forums/en-US/… Jun 13, 2013 at 13:51
  • I tried that code, but it kept throwing errors. I found another example though that worked first try.
    – Peter
    Jun 13, 2013 at 14:27
  • Just to note: as @KevinMcKeown has pointed out below, a Wiki page does not have a title. Jun 23, 2015 at 11:42
1

If you look at the content type for a Wiki Page, or at the default columns list in Library Settings for the Wiki Page library, you will notice that "Title" is not an available column. This may be causing you problems. It also causes an error in SharePoint 2013 when you try to click the "Shared With" ribbon button for a wiki page item.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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