How to get list of SharePoint Lists in SharePoint 2013 Online using CSOM

In this post, we’ll see how to get the list of the SharePoint List in SharePoint 2013 Online using CSOM.

Open Visual Studio 2013.

File –> New –> Project –> Visual C# –> Console Application  and name it as ‘ReadSharePointLists’

Add a reference to assemblies ‘Microsoft.SharePoint.Client’ and ‘Microsoft.SharePoint.Client.Runtime’.

Import the following two namespaces.

using Microsoft.SharePoint.Client;
using System.Security;

Copy and paste the following snippet of the code that will help us to fetch the list of SharePoint lists in the SharePoint Online site.

namespace ReadSharePointLists
    class Program
        static void Main(string[] args)
            //Replace it with the url of your tenant or your site-collection
            string SiteUrl = "";

            System.Uri oUri = new System.Uri(SiteUrl);

            using (ClientContext oClientContext = new ClientContext(SiteUrl))
                //Replace it with your user id for SharePoint Online
                string UserName = "";

                //Replace it with your password
                string Password = "password";

                //Create a SecureString object from password string, needed for SharePointOnlineCredentials class
                SecureString SecurePassword = GetSecureString(Password);
                oClientContext.Credentials = new SharePointOnlineCredentials(UserName, SecurePassword);

                //load the properties of web object
                Web oWeb = oClientContext.Web;
                //Get all the lists in the web

                foreach (List oList in oWeb.Lists)



        private static SecureString GetSecureString(String Password)
            SecureString oSecurePassword = new SecureString();

            foreach (Char c in Password.ToCharArray())

            return oSecurePassword;



After executing this we’ll see the below result, which displays the names of the SharePoint lists in the SharePoint 2013 Online site.clip_image002

 Subscribe to my blog

Leave a Reply