9

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"
    }
  }
}
tshepang
  • 12,111
  • 21
  • 91
  • 136
Erick B
  • 478
  • 5
  • 11
  • This is a long-shot, but is there anything further in the InnerError? https://learn.microsoft.com/en-us/graph/errors?context=graph%2Fapi%2Fbeta&view=graph-rest-beta#error-resource-type – Paul Schaeflein Sep 13 '19 at 22:00
  • no, anything else in the InnerError – Erick B Sep 14 '19 at 13:20
  • 1
    I'm sometimes having the same error when getting a calendar with a delta token. It seems to occur when Outlook is updating the mailbox local cache. I had to implement delayed retry logic to workaround it. – bN_ Jun 30 '20 at 15:48

5 Answers5

2

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

falkon13
  • 45
  • 6
  • 1
    After checking the linked github's issues related to this same problem, they all say to post here on stackoverflow ;) – Herz3h Dec 28 '20 at 07:53
1

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.

1

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++;
                }
            }
0

There is a high probability that the permission problem is caused, at least for me.

The following url should contain the permissions of almost all api applications. You can try to use the corresponding permissions as the value of the scope parameter to obtain authorization. https://learn.microsoft.com/zh-cn/graph/permissions-reference?view=graph-rest-1.0

For example, if I want to use the API of todo list, I should use it according to the description of the url above

https://learn.microsoft.com/zh-cn/graph/permissions-reference?view=graph-rest-1.0#application-permissions-65


很大的概率是权限问题导致的,至少我是这个问题。 在下面这个url中,应该包含了几乎所有api应用的权限,可以尝试把对应的权限作为scope参数的值用于获取授权。

https://learn.microsoft.com/zh-cn/graph/permissions-reference?view=graph-rest-1.0

例如,如果我想使用todo list的api,那么我应该根据上面url的说明使用 https://learn.microsoft.com/zh-cn/graph/permissions-reference?view=graph-rest-1.0#application-permissions-65

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 31 '22 at 16:32
-1

having the same issue - posted on their github: https://github.com/microsoftgraph/microsoft-graph-docs/issues/5853#issuecomment-660245066

➜  curl -vv -H "Authorization: $H" https://graph.microsoft.com/beta/me/messages\?%24filter\=isDraft+eq+false+and+lastModifiedDateTime+lt+2020-02-03T15%3A54%3A49Z\&%24orderby\=lastModifiedDateTime+desc\&%24skip\=34\&%24top\=1
*   Trying 20.190.132.119...
* TCP_NODELAY set
* Connected to graph.microsoft.com (20.190.132.119) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/cert.pem
  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=graph.microsoft.com
*  start date: Jul  1 21:55:17 2020 GMT
*  expire date: Jul  1 21:55:17 2022 GMT
*  subjectAltName: host "graph.microsoft.com" matched cert's "graph.microsoft.com"
*  issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT TLS CA 2
*  SSL certificate verify ok.
> GET /beta/me/messages?%24filter=isDraft+eq+false+and+lastModifiedDateTime+lt+2020-02-03T15%3A54%3A49Z&%24orderby=lastModifiedDateTime+desc&%24skip=34&%24top=1 HTTP/1.1
> Host: graph.microsoft.com
> User-Agent: curl/7.64.1
> Accept: */*
> Authorization: Bearer <TOKEN>
>
< HTTP/1.1 503 Service Unavailable
< Cache-Control: private
< Content-Type: application/json
< request-id: fe488121-fda3-439e-a059-435630a710a7
< client-request-id: fe488121-fda3-439e-a059-435630a710a7
< x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West US","Slice":"SliceC","Ring":"5","ScaleUnit":"003","RoleInstance":"AGSFE_IN_37"}}
< Strict-Transport-Security: max-age=31536000
< Date: Fri, 17 Jul 2020 17:30:42 GMT
< Content-Length: 198
<
{
  "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "date": "2020-07-17T17:30:42",
      "request-id": "fe488121-fda3-439e-a059-435630a710a7"
    }
  }
* Connection #0 to host graph.microsoft.com left intact
}* Closing connection 0
magicgregz
  • 7,471
  • 3
  • 35
  • 27