How to get wiki content from wiki page library SharePoint 365 using C# CSOM

Dhananjay Siwach 21 Reputation points
2021-03-26T04:18:55.347+00:00

Hi,

How to get wiki content from page versions( like 1.0, 2.0) Wiki Page Library in c# using CSOM.
there is no method to get content from versions.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,624 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,245 questions
0 comments No comments
{count} votes

Accepted answer
  1. Amos Wu-MSFT 4,051 Reputation points
    2021-03-26T07:05:14.857+00:00

    We could get the page content in the version.FieldValues property.

                 using (var clientContext = new ClientContext("https://contoso.sharepoint.com/sites/dev"))  
                 {  
                    // SharePoint Online Credentials    
                    clientContext.Credentials = new SharePointOnlineCredentials(userName, password);  
      
                    ListItem item = clientContext.Web.Lists.GetByTitle("Site Pages").GetItemById(44);  
                      
                    clientContext.Load(item,li=>li.Versions);  
                    clientContext.ExecuteQueryRetry();  
                         
                    foreach (ListItemVersion version in item.Versions)  
                    {      
                        Console.WriteLine(version.VersionLabel);  
                        Console.WriteLine(version.FieldValues["WikiField"]);  
                    }  
      
                    Console.ReadLine();  
                }  
    

    Test result:
    81794-image.png


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Dhananjay Siwach 21 Reputation points
    2021-03-26T09:28:15.947+00:00