Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Get list including items
The following example shows you how to get a list including list items.
C# example
using System; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Sites; using Independentsoft.Graph.QueryOptions; namespace ConsoleApp1 { class Program { static async Task Main() { try { GraphClient client = new GraphClient(); client.ClientId = "6333333-209e-454e-b7bd-55a4d201270f"; client.Tenant = "independentsoft.onmicrosoft.com"; client.Username = "info@independentsoft.onmicrosoft.com"; client.Password = "password"; Query query = new Query(); query.Expand.Add(ListPropertyName.Items); List list = await client.GetList("independentsoft.sharepoint.com,333333333-c666-4b40-bcd4-d771fb97ae69,73b98e9e-5749-407a-82b1-31d82fb30539", "333333333-2a3d-4235-9305-9f8bd6c7300a", query); Console.WriteLine("List Id: " + list.Id); Console.WriteLine("List Name: " + list.Name); Console.WriteLine("List DisplayName: " + list.DisplayName); Console.WriteLine("List CreatedTime: " + list.CreatedTime); Console.WriteLine("List WebUrl: " + list.WebUrl); Console.WriteLine("-----------------------------------------------------------------"); foreach (ListItem item in list.Items) { Console.WriteLine("Item Id: " + item.Id); Console.WriteLine("Item Name: " + item.Name); Console.WriteLine("-----------------------------------------------------------------"); foreach (ListItemField field in item.Fields) { Console.WriteLine("Field Name: " + field.Name); Console.WriteLine("Field Value: " + field.Value); 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.Sites Imports Independentsoft.Graph.QueryOptions 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 query As Query = New Query() query.Expand.Add(ListPropertyName.Items) Dim list As List = Await client.GetList("independentsoft.sharepoint.com,3333333-c666-4b40-bcd4-d771fb97ae69,73b98e9e-5749-407a-82b1-31d82fb30539", "3333333-2a3d-4235-9305-9f8bd6c7300a", query) Console.WriteLine("List Id: " & list.Id) Console.WriteLine("List Name: " & list.Name) Console.WriteLine("List DisplayName: " & list.DisplayName) Console.WriteLine("List CreatedTime: " & list.CreatedTime) Console.WriteLine("List WebUrl: " & list.WebUrl) Console.WriteLine("-----------------------------------------------------------------") For Each item As ListItem In list.Items Console.WriteLine("Item Id: " & item.Id) Console.WriteLine("Item Name: " & item.Name) Console.WriteLine("-----------------------------------------------------------------") For Each field As ListItemField In item.Fields Console.WriteLine("Field Name: " & field.Name) Console.WriteLine("Field Value: " & field.Value) Console.WriteLine("-----------------------------------------------------------------") Next 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*