POST https://graph.microsoft.com/v1.0/me/todo/lists/AQMkADAwATM0MDAAMS0yMDkyLWVjMzYtM/tasks
Content-Type: application/json
{
"title":"A new task",
"categories": ["Important"],
"linkedResources":[
{
"webUrl":"http://microsoft.com",
"applicationName":"Microsoft",
"displayName":"Microsoft"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new TodoTask
{
Title = "A new task",
Categories = new List<string>
{
"Important",
},
LinkedResources = new List<LinkedResource>
{
new LinkedResource
{
WebUrl = "http://microsoft.com",
ApplicationName = "Microsoft",
DisplayName = "Microsoft",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Todo.Lists["{todoTaskList-id}"].Tasks.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewTodoTask()
title := "A new task"
requestBody.SetTitle(&title)
categories := []string {
"Important",
}
requestBody.SetCategories(categories)
linkedResource := graphmodels.NewLinkedResource()
webUrl := "http://microsoft.com"
linkedResource.SetWebUrl(&webUrl)
applicationName := "Microsoft"
linkedResource.SetApplicationName(&applicationName)
displayName := "Microsoft"
linkedResource.SetDisplayName(&displayName)
linkedResources := []graphmodels.LinkedResourceable {
linkedResource,
}
requestBody.SetLinkedResources(linkedResources)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
tasks, err := graphClient.Me().Todo().Lists().ByTodoTaskListId("todoTaskList-id").Tasks().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TodoTask todoTask = new TodoTask();
todoTask.setTitle("A new task");
LinkedList<String> categories = new LinkedList<String>();
categories.add("Important");
todoTask.setCategories(categories);
LinkedList<LinkedResource> linkedResources = new LinkedList<LinkedResource>();
LinkedResource linkedResource = new LinkedResource();
linkedResource.setWebUrl("http://microsoft.com");
linkedResource.setApplicationName("Microsoft");
linkedResource.setDisplayName("Microsoft");
linkedResources.add(linkedResource);
todoTask.setLinkedResources(linkedResources);
TodoTask result = graphClient.me().todo().lists().byTodoTaskListId("{todoTaskList-id}").tasks().post(todoTask);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\TodoTask;
use Microsoft\Graph\Generated\Models\LinkedResource;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TodoTask();
$requestBody->setTitle('A new task');
$requestBody->setCategories(['Important', ]);
$linkedResourcesLinkedResource1 = new LinkedResource();
$linkedResourcesLinkedResource1->setWebUrl('http://microsoft.com');
$linkedResourcesLinkedResource1->setApplicationName('Microsoft');
$linkedResourcesLinkedResource1->setDisplayName('Microsoft');
$linkedResourcesArray []= $linkedResourcesLinkedResource1;
$requestBody->setLinkedResources($linkedResourcesArray);
$result = $graphServiceClient->me()->todo()->lists()->byTodoTaskListId('todoTaskList-id')->tasks()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.todo_task import TodoTask
from msgraph.generated.models.linked_resource import LinkedResource
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TodoTask(
title = "A new task",
categories = [
"Important",
],
linked_resources = [
LinkedResource(
web_url = "http://microsoft.com",
application_name = "Microsoft",
display_name = "Microsoft",
),
],
)
result = await graph_client.me.todo.lists.by_todo_task_list_id('todoTaskList-id').tasks.post(request_body)