This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Fetching the members of a group who are of the type User | |
var usersInGroup = await graphServiceClient | |
.Groups["group-id"] | |
.Members | |
.GraphUser //cast to User | |
.GetAsync(); | |
List<User> userList = usersInGroup.Value; | |
//Similarly, members of the group of type ServicePrincipal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count = await graphServiceClient | |
.Users | |
.Count //Where applicable to enable the use of $count | |
.GetAsync(requestConfiguration => | |
requestConfiguration.Headers.Add("ConsistencyLevel","eventual")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TokenProvider : IAccessTokenProvider | |
{ | |
public Task<string> GetAuthorizationTokenAsync(Uri uri, | |
Dictionary<string, | |
object> additionalAuthenticationContext = default, | |
CancellationToken cancellationToken = default) | |
{ | |
var token = "token"; | |
//get the token and return it in your own way | |
return Task.FromResult(token); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
await graphServiceClient.Me.PatchAsync(user); | |
} | |
catch (ODataError odataError) | |
{ | |
Console.WriteLine(odataError.Error.Code); | |
Console.WriteLine(odataError.Error.Message); | |
throw; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var usersResponse = await graphServiceClient | |
.Users | |
.GetAsync(requestConfiguration => { | |
requestConfiguration.QueryParameters.Select = new string[] {"id", "createdDateTime"}; | |
requestConfiguration.QueryParameters.Top = 1; }); | |
var userList = new List<User>(); | |
var pageIterator = PageIterator<User,UserCollectionResponse> | |
.CreatePageIterator(graphServiceClient,usersResponse, (user) => { | |
userList.Add(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var usersResponse = await graphServiceClient | |
.Users | |
.GetAsync(requestConfiguration => | |
requestConfiguration.QueryParameters.Select = new string[] {"id", "createdDateTime"}); | |
List<User> userList = usersResponse.Value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get the object | |
var @event = await graphServiceClient | |
.Me.Events["event-id"] | |
.GetAsync(); | |
//the backing store will keep track that the property change and send the updated value. | |
@event.Recurrence = null;// set to null | |
//update the object | |
await graphServiceClient.Me.Events["event-id"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//create user using v5 | |
var user = new User() | |
{ | |
DisplayName= "Adele V", | |
}; | |
await graphServiceClient | |
.Users | |
.PostAsync(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//create user using v4 | |
var user = new User() | |
{ | |
DisplayName = "Adele V", | |
}; | |
await graphServiceClient | |
.Users | |
.Request() | |
.AddAsync(user); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//var message = .... | |
//var saveToSentItems = ... | |
var body = new SendMailPostRequestBody | |
{ | |
Message = message, | |
SaveToSentItems = saveToSentItems | |
}; | |
await graphServiceClient.Me |