microsoftgraph / msgraph-sdk-dotnet

Microsoft Graph Client Library for .NET!
https://graph.microsoft.com
Other
690 stars 246 forks source link

DirectoryObjects.GetByIds and select in v5 #1975

Open StefanSchoof opened 1 year ago

StefanSchoof commented 1 year ago

Is your feature request related to a problem? Please describe. The Graph API has a know issue with getByIds https://learn.microsoft.com/en-us/graph/known-issues#incomplete-objects-are-returned-when-using-getbyids-request With the graph sdk v4 it was possible to use this:

                var dictionaryObjects = await graphServiceClient.DirectoryObjects
                    .GetByIds(chunk)
                    .Request()
                    .Select("id,type,displayName,mailNickname")
                    .PostAsync();

Describe the solution you'd like A way to use the select parameter with the getByIds Post method in v5

Describe alternatives you've considered Stay on v4

or

use the ToPostRequestInformation and overwrite the URI

                var ri = graphServiceClient.DirectoryObjects.GetByIds.ToPostRequestInformation(
                    new Microsoft.Graph.DirectoryObjects.GetByIds.GetByIdsPostRequestBody()
                    {
                        Ids = chunk.ToList(),
                    }
                );
                ri.URI = new Uri(ri.URI + "?$select=id,type,displayName,mailNickname");
                var dictionaryObjects =
                    await graphServiceClient.RequestAdapter.SendAsync<GetByIdsResponse>(
                        ri,
                        GetByIdsResponse.CreateFromDiscriminatorValue
                    );

Additional context Add any other context or screenshots about the feature request here.

Matthewsre commented 4 months ago

I have some code that's been stuck on V4 for quite a long time now due to issues like this one and the similar break with #skiptoken/pagination running into the same types of issues where you have to manually edit/append the URI to try and work around it. Is there any guidance for these issues to make the V5 SDK more usable?