@Vicky Kumar (Mindtree Consulting PVT LTD) Thanks for reply. We are using async call and in try catch its giving error generalException
Message : An error occurred sending the request. Thus unable to figure out what is the error.
Microsoft graph code general exception using Graph client in C#
We are calling Graph client method to get user details and and message details but its not working.
code :
IConfidentialClientApplication app;
app = ConfidentialClientApplicationBuilder.Create("{client id}")
.WithClientSecret("{client secret}")
//.WithRedirectUri("https://jwt.ms")
.WithAuthority(new Uri("https://login.microsoftonline.com/{tenant id}"))
.Build();
AuthenticationResult result;
string[] scopes = new string[] { "https://graph.microsoft.com/.default" };
result = await app.AcquireTokenForClient(scopes).ExecuteAsync();
/*string accesstoken = result.AccessToken;
Console.WriteLine(accesstoken);*/
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var message = await graphClient.Users["{user id}"].Messages["{message id}"]
.Request()
.GetAsync();
When we run application using visual studio 2-17 using C# its working fine without any error but when we deploy build files of application to the project folder location which is addin to outlook its not working and giving below exception
Exception : Code : generalException
Message : An error occurred sending the request
stack trace :
at Microsoft.Graph.HttpProvider.<SendRequestAsync>d__19.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Cant understand what is exact root cause of this error and how to fix this.
1 answer
Sort by: Most helpful
-
SAC_535 36 Reputation points
2022-04-04T05:35:44.703+00:00