Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph JS
>
Tutorial
> Create TodoTask
The following example creates a TodoTask in the specified task list.
import { GraphClient, ItemBody, ContentType } from '../independentsoft/graph/graph.js'; import { TodoTask } from '../independentsoft/graph/todo.js'; async function mainFunc() { try { const client = new GraphClient(); client.clientId = "xxxxxxxxxx-209e-454e-xxxxxxxxxxxxxxxxxxx"; client.tenant = "independentsoft.onmicrosoft.com"; client.username = "info@independentsoft.onmicrosoft.com"; client.password = "password"; const todoTaskLists = await client.getTodoTaskLists(); for (let i = 0; i < todoTaskLists.length; i++) { if(todoTaskLists[i].name === "Tasks") { let newTask = new TodoTask(); newTask.title = "New Task"; newTask.body = new ItemBody("Body text", ContentType.TEXT); const createdTodoTask = await client.createTodoTask(todoTaskLists[i].id, newTask); } } } catch (e) { console.error(e.code) //error code console.error(e.message) //description console.error(e.date) //timestamp console.error(e.innerError) //innerError } } mainFunc();
Need help? Ask our developers:
Name*
Email*
Message*