question

DhananjaySiwach avatar image
0 Votes"
DhananjaySiwach asked AmosWu-MSFT commented

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

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.

dotnet-csharpoffice-sharepoint-online
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AmosWu-MSFT avatar image
1 Vote"
AmosWu-MSFT answered

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.


image.png (218.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

DhananjaySiwach avatar image
0 Votes"
DhananjaySiwach answered AmosWu-MSFT commented

Thanks @AmosWu-MSFT

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You're welcome.

0 Votes 0 ·