Creating Wiki Page On SharePoint Online Using PnP Core CSOM Library


In this article, you will learn how to create a Wiki page on SharePoint Online site with various methods, using PnP Core CSOM library.

The main advantage of using PnP Core libraries is the reduced code to get/set the required information. The required object can be retrieved/created/updated with a very small piece of code, once the client context is set.


  • PnP Core CSOM documentation can be found on the official site here.

  • PnP Core CSOM library packages can be downloaded here

The code, given below, is being tested, using Visual Studio console application. Once the console application is created, the packages can be installed, using "Install-Package SharePointPnPCoreOnline" command on Package Manager console of Visual Studio. Once installed, the references and packages will be imported to the solution.

The references used in the sample are given below.

  • Microsoft.SharePoint.Client

  • OfficeDevPnP.Core 

Connect to SharePoint Online site

The Authentication Manager is used to retrieve the client context of the site. To connect to SharePoint Online site, the token, given below is used.

  • GetSharePointOnlineAuthenticatedContextToken 

The parameters required are.

  • SharePoint Online site URL

  • Tenant UserId

  • Tenant Password (or secured string)

Create Wiki page

In this approach, you will learn about the creation of a Wiki page on a Wiki page library.

The following steps explain the process in detail.

  • Input the site detail, user details for authentication, and page details.

  • Authenticate and get the client context of the site and then the necessary Web object.

  • Using Web object, add the wiki page to the wiki pages library using AddWikiPage method. The required parameters are given below.

  1. Page library name

  2. Page name

  • Display the results.

The following code snippet shows you the way to create a wiki page.