Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

I found a working example at 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.

share|improve this answer
    
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. –  avishnyakov Jun 14 '13 at 9:46

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"

share|improve this answer
    
Do I need to specify the content type so that it will know which columns are available? –  Peter Jun 13 '13 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! –  Robert Lindgren Jun 13 '13 at 13:49
    
Oh, but look what I found! social.technet.microsoft.com/forums/en-US/… –  Robert Lindgren Jun 13 '13 at 13:51
    
I tried that code, but it kept throwing errors. I found another example though that worked first try. –  Peter Jun 13 '13 at 14:27

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.

share|improve this answer

Your Answer

 
discard

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.