Reputation: 514
Does anyone know what to do when you get "UnknownError" from Graph API?
Response:
{
"error": {
"code": "UnknownError",
"message": "",
"innerError": {
"request-id": "1ea27a29-5491-44d2-824a-0aaee9280c40",
"date": "2019-09-13T19:48:30"
}
}
}
Upvotes: 12
Views: 9947
Reputation: 1
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
Upvotes: 0
Reputation: 1
Replace the principle user id with the application object id
See reference https://learn.microsoft.com/en-us/graph/api/application-post-onlinemeetings?view=graph-rest-1.0&tabs=http#http-request
Upvotes: 0
Reputation: 7679
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
Upvotes: -1
Reputation: 11
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++;
}
}
Upvotes: 1
Reputation: 46
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.
Upvotes: 2
Reputation: 55
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
Upvotes: 3