Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Get lists in a site
The following example shows you how to get the collection of lists for a site.
C# example
using System; using System.Collections.Generic; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Groups; using Independentsoft.Graph.Sites; namespace ConsoleApp1 { class Program { static async Task Main() { try { GraphClient client = new GraphClient(); client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.Username = "info@independentsoft.onmicrosoft.com"; client.Password = "password"; IList
lists = await client.GetLists("independentsoft.sharepoint.com,3333333-c666-4b40-bcd4-d771fb97ae69,73b98e9e-5749-407a-82b1-31d82fb30539"); foreach (List list in lists) { Console.WriteLine("Id: " + list.Id); Console.WriteLine("Name: " + list.Name); Console.WriteLine("DisplayName: " + list.DisplayName); Console.WriteLine("CreatedTime: " + list.CreatedTime); Console.WriteLine("WebUrl: " + list.WebUrl); Console.WriteLine("-----------------------------------------------------------------"); } Console.Read(); } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); Console.Read(); } } } }
VB example
Imports Independentsoft.Graph Imports Independentsoft.Graph.Groups Imports Independentsoft.Graph.Sites Namespace Sample Class Module1 Shared Sub Main(ByVal args As String()) Dim task = New Task(AddressOf Run) ' Start and wait for task to end. task.Start() Console.Read() End Sub Shared Async Sub Run() Try Dim client As GraphClient = New GraphClient() client.ClientId = "63333333-209e-454e-b7bd-55a4d201270f" client.Tenant = "independentsoft.onmicrosoft.com" client.Username = "info@independentsoft.onmicrosoft.com" client.Password = "password" Dim lists As IList(Of List) = Await client.GetLists("independentsoft.sharepoint.com,33333333-c666-4b40-bcd4-d771fb97ae69,73b98e9e-5749-407a-82b1-31d82fb30539") For Each list As List In lists Console.WriteLine("Id: " & list.Id) Console.WriteLine("Name: " & list.Name) Console.WriteLine("DisplayName: " & list.DisplayName) Console.WriteLine("CreatedTime: " & list.CreatedTime) Console.WriteLine("WebUrl: " & list.WebUrl) Console.WriteLine("-----------------------------------------------------------------") Next Console.Read() Catch ex As GraphException Console.WriteLine("Error: " + ex.Code) Console.WriteLine("Error: " + ex.Message) Console.Read() End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*