Microsoft graph code general exception using Graph client in C#

SAC_535 31 Reputation points

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}")
.WithAuthority(new Uri("{tenant id}"))

         AuthenticationResult result;

         string[] scopes = new string[] { "" };

         result = await app.AcquireTokenForClient(scopes).ExecuteAsync();

         /*string accesstoken = result.AccessToken;


         GraphServiceClient graphClient = new GraphServiceClient(authProvider);

         var message = await graphClient.Users["{user id}"].Messages["{message id}"]

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.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
9,174 questions
{count} vote

1 answer

Sort by: Most helpful
  1. SAC_535 31 Reputation points

    @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.

    0 comments No comments