How to get wiki content from wiki page library of SharePonint On Premise 2016/19 via CSOM c#

Amit Singh Rawat 731 Reputation points
2021-11-17T08:29:59.167+00:00

Hi,
I followed below link to download content of WikiPageLibrary for SharePoint OnPremise :

https://learn.microsoft.com/en-us/answers/questions/332480/how-to-get-wiki-content-from-wiki-page-library-sha.html

But above link is working for Online only and throw exception in case of OnPremise 2016 and 2019 server.
Error: Field or property "Versions" does not exist

Also in Online as well, it is not downloading attachment content.

Kindly confirm how can we read content or WikiPage library and it's version along with attachemnts in OnPremise via CSOM C#

Microsoft 365 and Office | SharePoint Server | For business
Microsoft 365 and Office | SharePoint Server | Development
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MichaelHan-MSFT 18,126 Reputation points
    2021-11-18T02:44:52.26+00:00

    Hi @Amit Singh Rawat ,

    In sharepoint on OnPremise CSOM, there is no exist api to get the versions of the items. That's why you get the error. If you want to get version history of a list item, you may need to use SharePoint web service to retrieve the version history and related data of list item In client-side. You could refer to this post: https://social.msdn.microsoft.com/Forums/SqlServer/en-US/177ceafb-debd-4020-b943-904c220cbf5f/how-to-get-list-item-versions-using-csom?forum=appsforsharepoint

    And we could get the content for a wiki page like this:

            ListItem item = web.Lists.GetByTitle("Site Pages").GetItemById(11);  
            ctx.Load(item);  
            ctx.ExecuteQuery();              
            Console.WriteLine(item["WikiField"]);  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.