question

AmitRawat-3636 avatar image
0 Votes"
AmitRawat-3636 asked AmitRawat-3636 commented

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

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

https://docs.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#

office-sharepoint-server-administrationoffice-sharepoint-server-development
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.

1 Answer

MichaelHan-MSFT avatar image
1 Vote"
MichaelHan-MSFT answered AmitRawat-3636 commented

Hi @AmitRawat-3636,

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.





· 5
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.

@MichaelHan-MSFT
As per last comment "lists.asmx has been deprecated and Microsoft do not provide any further support on this.".
I just wanted to get content and attachments of WikiPageLibrary. I manages to get FileVersions.
Is there any simple workaround. I don't want to touch SharePoint server at all.

0 Votes 0 ·

@AmitRawat-3636,

FileVesions object does not contain the content of wiki page.

There is no any other workaround. Client Object Model doesn't provide versions property (which is available only on Server Side Object Model).

The same issue has been asked here: https://sharepoint.stackexchange.com/questions/128527/get-list-item-version-history-using-client-side-object-model-c

0 Votes 0 ·

@AmitRawat-3636,

Did you have a try to michael's answer above? Is there any progress?

0 Votes 0 ·

@AmitRawat-3636,
I’m checking how the things are going on about this issue.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

0 Votes 0 ·

Hi @MichaelHan-MSFT ,
I was on vacation, will test this week and let you know.

0 Votes 0 ·