Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph .NET
>
Tutorial
> Create TodoTask
The following example creates a TodoTask in the specified task list.
C# example
using System; using System.Collections.Generic; using System.Threading.Tasks; using Independentsoft.Graph; using Independentsoft.Graph.Todo; 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
todoTaskLists = await client.GetTodoTaskLists(); foreach (TodoTaskList list in todoTaskLists) { if(list.DisplayName == "Tasks") { TodoTask newTask = new TodoTask(); newTask.Title = "New Task"; newTask.Body = new ItemBody("Body text", ContentType.Text); TodoTask createdTodoTask = await client.CreateTodoTask(list.Id, newTask); } } } catch (GraphException ex) { Console.WriteLine("Error: " + ex.Code); Console.WriteLine("Message: " + ex.Message); } } } }
VB example
Imports System.Collections.Generic Imports Independentsoft.Graph Imports Independentsoft.Graph.Todo 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 todoTaskLists As IList(Of TodoTaskList) = Await client.GetTodoTaskLists() For Each list As TodoTaskList In todoTaskLists If list.DisplayName = "Tasks" Then Dim newTask As TodoTask = New TodoTask() newTask.Title = "New Task" newTask.Body = New ItemBody("Body text", ContentType.Text) Dim createdTodoTask As TodoTask = Await client.CreateTodoTask(list.Id, newTask) End If Next Catch ex As GraphException Console.WriteLine("Error: " + ex.Code) Console.WriteLine("Error: " + ex.Message) End Try End Sub End Class End Namespace
Need help? Ask our developers:
Name*
Email*
Message*