microsoftgraph / microsoftgraph/msgraph-sdk-dotnet

Graph SDK Dotnet 5 (Graph api v5) call to get lists in a sharepoint site not listing all lists

Open
#2,417 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Question: SDK
Dominant language
C#
Stars
789
Forks
264
Avg merge
15h 17m
Merged PRs (30d)
3

Description

I'm using graph api v5 (sdk for dotnet) to get sharepoint lists in a site. As explained in below Microsoft documentation I've used system facet in select query to get the lists. https://learn.microsoft.com/en-us/graph/api/list-list?view=graph-rest-1.0&tabs=csharp . But this is not returning all the lists in the sharepoint site, I get some lists though.

Here is my code

 
var result = await graphClient.Sites[siteId].Lists.GetAsync((requestConfiguration) =>
 {
       requestConfiguration.QueryParameters.Expand = new string[] { "drive" };
       requestConfiguration.QueryParameters.Select = new string[] { "system", "*" };
 });

Above code is returning only 50 lists in the site in the first page of results and a null nextLink . With previous version of graph sdk (v4) same code has returned 66 lists.

Tried another approach which also returning 50 lists.

 //requestInformation.UrlTemplate = requestInfo.UrlTemplate.Insert(requestInfo.UrlTemplate.Length   - 1, ",%24select,%24expand");
 requestInformation.QueryParameters.Add("%24select", "system,*");
 requestInformation.QueryParameters.Add("%24expand", "drive");
 
var result = await GraphServiceClient.RequestAdapter.SendAsync<ListCollectionResponse>(requestInformation, ListCollectionResponse.CreateFromDiscriminatorValue);

I've used the sdk generated url in graph explorer, that also returned only 50 lists. Could anyone help me with this c# code to get all the lists in a site?

Note: With the second approach if I enable the line which is commented, I get an exception "The server returned an unexpected status code and no error factory is registered for this code: 400". This is thrown from at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter as per the stack trace.
Thanks

Client version
5.37, 5.44.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the documented List API request and the GraphServiceClient.Sites[siteId].Lists.GetAsync call shown in the issue, then compare its generated request with the same query in Graph Explorer. Check how the response and nextLink are handled for the 50-item result and investigate the 400 response from the commented URL-template change. Done means identifying why the remaining lists are omitted and documenting or validating a working request.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.