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 user = await graphServiceClient | |
.Users["{user-id}"] | |
.GetAsync(requestConfiguration => | |
{ | |
requestConfiguration.Headers.Add("ConsistencyLevel","eventual"); | |
requestConfiguration.QueryParameters.Select = new string[] { "id", "createdDateTime"}; | |
}); |
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
InteractiveBrowserCredential interactiveBrowserCredential = new ("ClientID"); | |
//create client for calling v1 endpoint and get my info | |
Microsoft.Graph.GraphServiceClient graphServiceClient = new (tokenCredential, scopes); | |
var userFromV1 = await graphServiceClient.Me.GetAsync(); | |
//create client for calling beta endpoint and get my info | |
Microsoft.Graph.Beta.GraphServiceClient betaGraphServiceClient = new(tokenCredential, scopes); | |
var userFromBeta = await betaGraphServiceClient.Me.GetAsync(); |
OlderNewer