How to programmatically create a wiki page (= item) in Sharepoint?

how to create a wiki page and add a title, as well as some content in sharepoint (via webservices)?

This is my SOAP post:

<soapenv:Body> <soap:UpdateListItems> <soap:listName>Cooking Wiki</soap:listName> <soap:updates> <Batch OnError="Continue"> <Method ID="1" Cmd="New"> <Field Name="WikiField">Mix two eggs and a cup of milk.</Field> </Method> </Batch> </soap:updates> </soap:UpdateListItems> </soapenv:Body> 

Creates a new page, but it has no content and no title.

+4
source share
4 answers

Take a copy of SharePoint Manager , it can show you a bunch of interesting information.

you need a Name field (it includes ".aspx"). The title field is not related to the wiki (empty), pages are indexed by their name.

- update -

Using copy.asmx allows you to load a new document. A template page is a page that was previously loaded (it does not store any information equivalent to a layout page).

 private byte[] GetTemplatePage() { FileStream fs = new FileStream("templatePage.aspx", FileMode.Open); byte[] fileContents = new byte[(int)fs.Length]; fs.Read(fileContents, 0, (int)fs.Length); fs.Close(); return fileContents; } private void UploadDoc(string pageName) { byte[] wikiBytes = GetTemplatePage(); string dest = "http://[website]/wiki/Wiki%20Pages/" + pageName + ".aspx"; string[] destinationUrlArray = new string[] { dest }; IntranetCopy.Copy copyService = new IntranetCopy.Copy(); copyService.UseDefaultCredentials = true; copyService.Url = "http://[website]/wiki/_vti_bin/copy.asmx"; IntranetCopy.FieldInformation fieldInfo = new IntranetCopy.FieldInformation(); IntranetCopy.FieldInformation[] fields = { fieldInfo }; IntranetCopy.CopyResult[] resultsArray; copyService.Timeout = 600000; uint documentId = copyService.CopyIntoItems(dest, destinationUrlArray, fields, wikiBytes, out resultsArray); } 

You can then call lists.asmx to update wikifield. Note. I do not understand how to rename a document after downloading it using webservices.

+4
source

Dan Winter wrote a fantastic application that I think could provide some sample code, take a look at it here:

Wikimigrator

Or, for more information, read his detailed blog posts .

+1
source

If nothing works, you should develop your own web service to provide this feature. The original options are known to be limited in functionality, but there is nothing to prevent you from adding to them.

I would wrap the Nat solution in a web service code.

+1
source

Source: https://habr.com/ru/post/1285958/


All Articles