Forum Discussion
Graph API 1.0 - Listing lists doesn't return all lists (todoTaskList)
I have experienced the same issue retrieving Microsoft To Do list records through the Microsoft Graph SDK.
I have more than 50 lists.
I have observed that without a filter (StartsWith = ""), I get only "Flagged Emails" back.
If I use a filter like startswith(displayName, 'A') I get a list of lists with names beginning with "A".
If I use a filter like this:
startswith(displayName, 'A') OR startswith(displayName, 'B') OR startswith(displayName, 'C') OR startswith(displayName, 'D') OR startswith(displayName, 'E') OR startswith(displayName, 'F') OR startswith(displayName, 'G') OR startswith(displayName, 'H') OR startswith(displayName, 'I') OR startswith(displayName, 'J') OR startswith(displayName, 'K') OR startswith(displayName, 'L') OR startswith(displayName, 'M') OR startswith(displayName, 'N') OR startswith(displayName, 'O') OR startswith(displayName, 'P') OR startswith(displayName, 'Q') OR startswith(displayName, 'R') OR startswith(displayName, 'S') OR startswith(displayName, 'T') OR startswith(displayName, 'U') OR startswith(displayName, 'V') OR startswith(displayName, 'W') OR startswith(displayName, 'X') OR startswith(displayName, 'Y') OR startswith(displayName, 'Z')
I get only some of my lists. The list of lists returns in alphabetical order. At some point, the list just truncates and appends "Flagged Emails" to the end.
If I delete the OR startswith(displayName, 'T') filter, then the lists not shown in the previous (entire alphabet) search show up. It's as if removing lists that begin with "T" freed up space somewhere for the lists ignored in the previous search. (Lists starting with "T" are the most lists.)
I can get any list by filtering for an exact match on displayName.
I tried with and without pagination. Same results.
I log in as a consumer, with my Microsoft 365 account in a browser.
Trying to get a consistent response from Microsoft Graph is difficult. Removing lists with names that start with one letter affect Microsoft Graph results differently than removing a different letter. Like standing on a disc balanced on a sphere, I'm always compensating for one change but never getting back all lists.
Microsoft Graph 5.90.0
===============
private async Task SignInAsync()
{
_credential = new InteractiveBrowserCredential(new InteractiveBrowserCredentialOptions
{
TenantId = TenantId,
ClientId = ClientId,
RedirectUri = new Uri("http://localhost")
});
_graphClient = new GraphServiceClient(_credential, Scopes);
await LoadListsAsync();
}
private async Task LoadListsAsync()
{
Lists.Clear();
var response = await _graphClient
.Me
.Todo
.Lists
.GetAsync(cfg =>
{
cfg.QueryParameters.Filter = StartsWith;
}
);
foreach (var list in response.Value)
{
Lists.Add(list);
}
}
Thank you so much for sharing this! Unfortunately I didn't receive a notification for this reply, but will give it a shot now and see if it helps in my case! It's a shame the API doesn't return all stored regular task lists by default and we have to resort to these (incomplete) hacks.