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(); |
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 | |
.MicrosoftGraphUser | |
.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 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 message = .... | |
//var saveToSentItems = ... | |
var body = new SendMailPostRequestBody | |
{ | |
Message = message, | |
SaveToSentItems = saveToSentItems | |
}; | |
await graphServiceClient.Me |
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
//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
//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
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
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
try | |
{ | |
await graphServiceClient.Me.PatchAsync(user); | |
} | |
catch (ODataError odataError) | |
{ | |
Console.WriteLine(odataError.Error.Code); | |
Console.WriteLine(odataError.Error.Message); | |
throw; | |
} |
OlderNewer