Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Graph API - "code": "UnknownError"

Does anyone know what to do when you get "UnknownError" from Graph API?

Request: https://graph.microsoft.com/v1.0/users/[USER_ID]/messages?$select=id,receivedDateTime&$filter=receivedDateTime+ge+2016-09-13+and+receivedDateTime+lt+2019-09-14&$orderby=receivedDateTime+asc&$skip=25651&$top=1

Response:

{
  "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "request-id": "1ea27a29-5491-44d2-824a-0aaee9280c40",
      "date": "2019-09-13T19:48:30"
    }
  }
}
like image 849
Erick B Avatar asked Sep 13 '19 19:09

Erick B


People also ask

Is MS graph API deprecated?

Microsoft Graph is also more secure and resilient than Azure AD Graph. For this reason, Azure AD Graph has been on a deprecation path since June 30, 2020, and will be retired in the near future as we move all investments to Microsoft Graph.


3 Answers

I'm having the same error on another part of the Graph API. I'm lead to believe it's a permissions error, easiest way to test would most likely be to use the Graph Explorer.

https://developer.microsoft.com/en-us/graph/graph-explorer

Run the request there and assign yourself the relevant permissions.

If this doesn't work then the relevant place to raise this issue seems to be on the Graph API GitHub which is here https://github.com/microsoftgraph/microsoft-graph-docs

like image 189
falkon13 Avatar answered Sep 28 '22 00:09

falkon13


The HTTP error code would give you much more detail about what went wrong. If it's a 403 or 401, then it's an auth error. If it's 500, or 503, then it's a server error.

like image 41
Harvey Rook Avatar answered Sep 27 '22 23:09

Harvey Rook


I am getting the error more often now, on an application that retrieves file and folder stucture. My workaround is to detect the error, wait a little and retry.

IDriveItemChildrenCollectionPage folderitems = null;
            bool done = false;
            Int16 tries = 0;
            while (!done && tries < 3)
            {

                try
                {

                    DriveItem folderitem = null;
                    if (folder.Equals(""))
                        folderitem = SPclient.Sites[siteId].Lists[listId].Drive.Root.Request().GetAsync().Result;
                    else
                        folderitem = SPclient.Sites[siteId].Lists[listId].Drive.Root.ItemWithPath(folder).Request().GetAsync().Result;
                    folderitems = SPclient.Sites[siteId].Lists[listId].Drive.Items[folderitem.Id].Children.Request().GetAsync().Result;
                done = true;
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null && ex.InnerException.Message.StartsWith("Code: UnknownError"))
                    {
                        //wait, retry
                        System.Threading.Thread.Sleep(500);
                    }
                    else
                        throw;
                }
                finally
                {
                    tries++;
                }
            }
like image 43
Ole Martin Helgesen Avatar answered Sep 28 '22 00:09

Ole Martin Helgesen