leopik
leopik

Reputation: 2351

Getting all plans in Planner for current user using Microsoft Graph

I'm trying to get all plans for current user (basically get the same result as in Planner under "All plans" option).

To do that, I'm using Graph SDK (Microsoft.Graph.GraphServiceClient) and here is the very simple code that I'm using to achieve that:

// gc is an instance of GraphServiceClient
var result = await gc.Me.Planner.Plans.Request().GetAsync();

When debugging, I can see that result contains some plans, but definitely not all of them. After closer inspection it seems that this method returns plans found in Planner under "Recent plans". Therefore, if in native Planner I go to "All plans", open some of them and then invoke my code again, then I get the ones that I recently opened as well.

Is there anyway how to get all plans that the current user has access to programmatically?

Upvotes: 2

Views: 1016

Answers (1)

Tarkan Sevilmis
Tarkan Sevilmis

Reputation: 1508

The Planner UI builds the All Plans by first querying all the groups the user is a member, then for each of those groups retrieving the list of plans in the group. You can build the same logic, however that will require a lot of queries for users with many group memberships.

Note that All Plans is essentially the set of plans the user can access. For most scenarios, favorite and recent plans will cover the plans that are interesting to the user. Beta endpoint has queries available for these in the form of /me/planner/favoritePlans and /me/planner/recentPlans. These are not yet available on V1.0 endpoint.

Upvotes: 1

Related Questions