Microsoft Graph API-“代码”:“ UnknownError”

时间:2019-09-13 19:59:30

标签: microsoft-graph microsoft-graph-mail

当您从Graph API获得“ UnknownError”时,有人知道该怎么做吗? 还是询问微软的合适网站?

谢谢

请求: 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

响应:

{
  "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "request-id": "1ea27a29-5491-44d2-824a-0aaee9280c40",
      "date": "2019-09-13T19:48:30"
    }
  }
}

4 个答案:

答案 0 :(得分:0)

我在Graph API的另一部分遇到相同的错误。我认为这是一个权限错误,最容易测试的方法是使用Graph Explorer。

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

在此处运行请求并为自己分配相关权限。

如果这不起作用,则提出此问题的相关位置似乎在Graph API GitHub上,位于此处https://github.com/microsoftgraph/microsoft-graph-docs

答案 1 :(得分:0)

HTTP错误代码将为您提供更多有关错误原因的详细信息。如果是403或401,则是验证错误。如果是500或503,则是服务器错误。

答案 2 :(得分:0)

在检索文件和文件夹结构的应用程序上,我现在越来越经常出错。我的解决方法是检测错误,稍等片刻然后重试。

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

答案 3 :(得分:0)

有同样的问题-发布在其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