Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest release returns incorrect models for groups #2084

Closed
lebartha opened this issue Aug 18, 2023 · 3 comments · Fixed by microsoft/kiota#3187 or #2091
Closed

Latest release returns incorrect models for groups #2084

lebartha opened this issue Aug 18, 2023 · 3 comments · Fixed by microsoft/kiota#3187 or #2091
Assignees
Labels

Comments

@lebartha
Copy link

Hi,

Have the following code:

var groups = await graphClient.Users[user.UserPrincipalName].MemberOf.GetAsync();
bool isValidUser = groups.Value.Cast<Microsoft.Graph.Models.Group>().Any...

Version 5.22.0 returns the types of the elements correctly, Microsoft.Graph.Models.Group.
Latest version 5.23.0 returns the types as Microsoft.Graph.Models.DirectoryObject and fails to make the cast.

Exception:
System.InvalidCastException: 'Unable to cast object of type 'Microsoft.Graph.Models.DirectoryObject' to type 'Microsoft.Graph.Models.Group'.'

Stack Trace:
at System.Linq.Enumerable.d__971.MoveNext() at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func`2 predicate) at CaptivaApi.Helper.Utilities.IsAuthorized(String groupList) in W:\Source Code\Azure GitHub\ds-capture-dashboard-webapi\CaptivaApi\Helper\Utilities.cs:line 493

See attached screenshots.

Screenshot 2023-08-18 at 11 20 47 AM
Screenshot 2023-08-18 at 11 29 33 AM


Latest version of Visual Studio 2022 (17.7.1)
.NET Framework 4.8
Windows 11

@MartinM85
Copy link
Contributor

After the change in DirectoryObject.CreateFromDiscriminatorValue, I'm facing similar issue.

Maybe better solution instead of casting group on the client is to request server side casting

var groups = await graphClient.Users[user.UserPrincipalName].MemberOf.GraphGroup.GetAsync();

@andrueastman
Copy link
Member

Thanks for raising this @lebartha

As @MartinM85 mentioned, this is caused by the change in DirectoryObject.CreateFromDiscriminatorValue. This should be resolved in the next in the course of the week.

@andrueastman andrueastman self-assigned this Aug 21, 2023
@lebartha
Copy link
Author

Awesome. Thank you, that is good news!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants