微软图形API - "code": "UnknownError"

9

这可能是一个冒险,但 InnerError 中是否还有其他信息?https://learn.microsoft.com/en-us/graph/errors?context=graph%2Fapi%2Fbeta&view=graph-rest-beta#error-resource-type - Paul Schaeflein
不要在InnerError中包含任何其他内容。 - Erick B
1
有时候在使用增量令牌获取日历时会出现相同的错误。这似乎是因为Outlook正在更新邮箱本地缓存所致。我不得不实现延迟重试逻辑来解决这个问题。 - bN_
5个回答

2

1
在检查了与此相同问题相关的链接github的问题后,它们都说要在stackoverflow上发布;) - Herz3h

1

HTTP错误代码将为您提供更多有关出现问题的详细信息。如果是403或401,则是授权错误。如果是500或503,则是服务器错误。


这是一个504网关超时。 - Erick B
这个邮箱还持续出现504错误吗? 我注意到你正在执行$skip=25651&$top=1操作,你设置的时间查询窗口中有那么多的邮件吗? - Jeremy Thake MSFT

1

我现在更经常地遇到这个错误,这是一个检索文件和文件夹结构的应用程序。我的解决方法是检测错误,等待一段时间后重试。

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

很有可能权限问题是导致问题的原因,至少对我来说是这样。

以下网址应该包含几乎所有 API 应用程序的权限。您可以尝试使用相应的权限作为范围参数的值来获取授权。 https://learn.microsoft.com/zh-cn/graph/permissions-reference?view=graph-rest-1.0

例如,如果我想使用待办事项列表的 API,则应根据上述网址的描述使用它。

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

目前你的回答不够清晰,请编辑并添加更多细节,以帮助其他人理解它如何回答问题。你可以在帮助中心找到有关如何编写好答案的更多信息。 - Community

-1

遇到了同样的问题 - 在他们的 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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接