'Traversing through IGraphServiceCollectionPage
I have made a List of graph service collection page but I need to put if loop to see if email exits in the list. Can someone help me t traverse. This is the code
var authProvider = await GetAuthProvider();
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
List<User> users = new List<User>();
var user = await graphClient.Users.Request().GetAsync();
users.AddRange(user.CurrentPage.OfType<User>());
while (user.NextPageRequest != null)
{
user = await user.NextPageRequest.GetAsync();
users.AddRange(user.CurrentPage.OfType<User>());
}
I want to know if the string {email} exits in users if yes return true if not return exception. but cannot convert as getting error cannot convert type string to Users
Solution 1:[1]
As per your code, it doesn't contain email you have to go 1 level down. if you want to get the mail you need to use Messages.
This is the demo API to get emails in graph explorer - https://graph.microsoft.com/v1.0/users/{user ID}/messages
The best way is to debug your code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | vicky kumar |