Updating Wiki Lib Article contents.

Feb 27 at 5:25 PM
Edited Mar 2 at 2:39 AM
I am using SPServices (2014.02) to retrieve ("GetListItems") and update ("UpdateListItems") document and list content, but I am having issues updating Wiki Content. I need to read a Wiki of about 200 articles to find specific link references and rewrite these references with a new domain.

I am able to retrieve the Wiki content (CAMLViewFields: "ID", "FileRef", "LinkFilename", "WikiField") without issue, but my attempt to update the wiki Content is not as successful.

after processing the content for the GetListItems call, I am using the following code to update the Wiki Content of each Wiki article that needs to be rewritten:
$().SPServices({ 
    operation: "UpdateListItems", 
    async: false, 
    webURL: "http://doamin.com/sites/100/",
    listName: "Test_Wiki",
    ID: "200",
    valuepairs: [["WikiField","<div>..new HTML content..</div>"]], 
    completefunc: function (xData, Status) { 
        //trace('Trying to add data'); 
         window.console && console.log(xData.responseText);
    } 
}); 
The xData.responseText from each "UpdateListItems" service call appears to present a success status:
<?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <soap:Body>
            <UpdateListItemsResponse xmlns="http://schemas.microsoft.com/sharepoint/soap/">
                <UpdateListItemsResult>
                    <Results>
                        <Result ID="1,Update">
                            <ErrorCode>0x00000000</ErrorCode>
                            <z:row 
                                ows_ID="200" 
                                ows_ContentTypeId="0x0101080036EC9E0B8C9C7040AABB5C1DD1A05DEE" 
                                ows_ContentType="Wiki Page" 
                                ows_Created="2017-02-24 20:57:19" 
                                ows_Author="1;#Lastname, fname" 
                                ows_Modified="2017-02-27 15:16:55" 
                                ows_Editor="1;#Lastname, fname" 
                                ows__ModerationStatus="0" 
                                ows_FileRef="255;#sites/100/Test_Wiki/Test Article.aspx" 
                                ows_FileDirRef="255;#sites/100/Test_Wiki" 
                                   .....
                        </Result>
                    </Results>
                </UpdateListItemsResult>
            </UpdateListItemsResponse>
        </soap:Body>
</soap:Envelope>
With an "ErrorCode" of "0x00000000", the call appears to be successful, but when the Article is accessed using the Wiki Web page the WikiContent for the updated article has been flushed (empty).

Can anyone provide a recommended approach for updating content in a SharePoint Wiki. While the SharePoint Wiki appears to be similar to a document library (with fields such as "FileRef", "LinkFilename"), it does not appear that it is possible to upload a new document version as the "FileRef" is a reference to a SharePoint page, not specific content.

I would appreciate recommendations and if possible sample code.

Thx.