'Why do some MsGraph Api endpoints return a General unexpected exception whilst other are working ok

My first real attempt at using MsGraph. I am getting a GENEARL exception when using just 3 of the MsGraph Mail Apis (Delete, Update or Move) BUT NOT with other MsGraph Api's (Add folder, GetMessages, GetUsers , SendMail )

Exception Message - "Code: generalException\r\nMessage: Unexpected exception returned from the service.\r\nClientRequestId: 594c682a-faa3-4be5-903c-c96e6cb99b76\r\n"

Authentication ? Not likely - I am using the SAME graphServiceClient for all requests and authentication is working  
Authorization - All permissions are in a GRANTED State - See below for full set but relying primarily on - `Mail.ReadWrite, Mail.Send, Directory.Read.All`

Can't seem to find any help why some of these work and some fail.  Why the exception is a general one rather than something useful - I don't know either.

Snippets that Fail with the 'General Exception' described above. (i.e. Mail - Delete, Update or Move )

    await graphServiceClient
    .Users[userId]
    .Messages[messageId]
    .Request()
    .DeleteAsync();
    
    await graphServiceClient
    .Users[userId]
    .Messages[messageId]
    .Request()
    .UpdateAsync(message);          
    
    await graphServiceClient
    .Users[userId]
    .Messages[messageId]
    .Move(destFolderId)
    .Request()
    .PostAsync();

Snippets that WORK ok (i.e. Mail - Add folder, GetMessages, GetUsers , SendMail, GetMessage(With attachments))


    await graphServiceClient
                   .Users[userId]
                   .MailFolders[parentMailFolder]
                   .ChildFolders
                   .Request()
                   .AddAsync(mailFolder);       
    
    await graphServiceClient
                    .Users[userId]
                    .MailFolders[mailFolderName]
                    .Messages
                    .Request()
                    .Filter(filterString)                        
                    .OrderBy("receivedDateTime desc")
                    .Top(maxQty)
                    .GetAsync();                   
    
    await graphServiceClient
                    .Users[userId]
                    .MailFolders[mailFolderName]
                    .Messages
                    .Request()
                    .Filter(filterString)
                    .OrderBy("receivedDateTime")
                    .Top(maxQty)
                    .GetAsync();
                    
    await graphServiceClient
                    .Users[userId]
                    .SendMail(message, null)
                    .Request()
                    .PostAsync();                       
                    
    await graphServiceClient
                    .Users[userId]
                    .MailFolders[mailFolderName]
                    .Messages
                    .Request()
                    .Filter(filterString)
                    .Expand("attachments")
                    .GetAsync();

All permissions are in a GRANTED State                  
Calendars.Read      Application
Calendars.ReadWrite Application
Directory.Read.All  Delegated
Mail.Read           Application
Mail.ReadWrite      Application
Mail.Send           Application
User.Read           Delegated
User.Read.All       Application

Authority = "https://graph.microsoft.com", or tried Authority = AzureAuthorityHosts.AzurePublicCloud,

scope = "https://graph.microsoft.com/.default";

Ex Message


     "Code: generalException\r\nMessage: Unexpected exception returned from the service.\r\nClientRequestId: 594c682a-faa3-4be5-903c-c96e6cb99b76\r\n"
     Stacktrace
     "   at Microsoft.Graph.HttpProvider.<SendAsync>d__18.MoveNext()\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.Graph.BaseRequest.<SendRequestAsync>d__40.MoveNext()\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.Graph.BaseRequest.<SendAsync>d__34`1.MoveNext()\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()\r\n   at Microsoft.Graph.MessageRequest.<UpdateAsync>d__7.MoveNext()\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n   at MsGraph_ClassLibrary.MsGraphHelper.<UpdateMessageCategory>d__8.MoveNext() in C:\\Users\\mike\\source\\repos\\MsGraph_GetEmail_TestApp\\MsGraph_ClassLibrary\\MsGraphHelper.cs:line 200"



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source