0
votes

I would like to create an Application which automatically creates a Task in Microsoft Graph (Microsoft App -> "Planner") in .NET (C#).

I already got the Authentification done but im not sure how to create a new Task or update a existing Task because I don't understand the Syntax.

Screenshot of my Code

The Problem is that there are no examples for Plans in Graph for .Net only stuff for Web Apps and so on. Link to api-reference

Im using the latest Microsoft Graph .Net Library found here

I hope that someone can help me.

1
Please don't add screenshots of your code.chrjs
Okay. Iam really sorry. I thought its easier to read :PJoelZ
Please provide your source code instead.McMillan Cheng

1 Answers

2
votes

The general pattern of request formulation in the .NET SDK is that it parallels the REST API hierarchy ('planner' lives under the root, and has a child called 'tasks'), at the end of which you build the request by invoking Request(), followed by the action you want to take (.AddAsync, .GetAsync).

In this case, you first want to create a PlannerTask object that represents the task you want to create.

PlannerTask myTask = new PlannerTask();
myTask.PlanId = id; //a valid planner id
myTask.Title = "New task title";
PlannerTask createdTask = await graphClient.Planner.Tasks.Request().AddAsync(myTask);