Hello,
want to fetch the self(ME) conversation using client secret can anyone help me to get it ?
I am trying to get the self conversation in teams using Microsoft Graph API using Application credential and not delegate method but I always get the error of Microsoft.Graph.Models.ODataErrors.ODataError
This exception was originally thrown at this call stack:
Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.ThrowIfFailedResponse(System.Net.Http.HttpResponseMessage, System.Collections.Generic.Dictionary<string, Microsoft.Kiota.Abstractions.Serialization.ParsableFactory<Microsoft.Kiota.Abstractions.Serialization.IParsable>>, System.Diagnostics.Activity)
Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync<ModelType>(Microsoft.Kiota.Abstractions.RequestInformation, Microsoft.Kiota.Abstractions.Serialization.ParsableFactory<ModelType>, System.Collections.Generic.Dictionary<string, Microsoft.Kiota.Abstractions.Serialization.ParsableFactory<Microsoft.Kiota.Abstractions.Serialization.IParsable>>, System.Threading.CancellationToken)
Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync<ModelType>(Microsoft.Kiota.Abstractions.RequestInformation, Microsoft.Kiota.Abstractions.Serialization.ParsableFactory<ModelType>, System.Collections.Generic.Dictionary<string, Microsoft.Kiota.Abstractions.Serialization.ParsableFactory<Microsoft.Kiota.Abstractions.Serialization.IParsable>>, System.Threading.CancellationToken)
Microsoft.Graph.Users.Item.Chats.Item.Messages.MessagesRequestBuilder.GetAsync(System.Action<Microsoft.Graph.Users.Item.Chats.Item.Messages.MessagesRequestBuilder.MessagesRequestBuilderGetRequestConfiguration>, System.Threading.CancellationToken)
GraphTutorial.Demo.GetSelfConversation()
and want to fetch the ME conversation using client secret can anyone help me to get it ?
The code I'm using is :
var scopes = new[] { "https://graph.microsoft.com/.default" };
var options = new ClientSecretCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};
bool IsClientCredential = true;
if (IsClientCredential)
{
_clientSecretCredential = new ClientSecretCredential(TenantId, ClientId, ClientSecret, options);
_graphServiceClient = new GraphServiceClient(_clientSecretCredential, scopes);
}
var selfConversationMessages = _graphServiceClient.Users["user-id"].Chats[_selfConversationId].Messages.GetAsync().GetAwaiter().GetResult();
foreach (var message in selfConversationMessages.Value)
{
Console.WriteLine(message.Body.Content);
}