3

I work on a proof of concept using MS Graph. When i try to create a session for my Excel workbook with Microsoft Graph REST API (v1.0), I got an

error 500 FileOpenBaseDocumentCheckOperationFailed

{
  "error": {
    "code": "FileOpenBaseDocumentCheckOperationFailed",
    "message": "Service is unavailable. Please try again.",
    "innerError": {
      "request-id": "6419d49f-60b6-4273-8be3-78f422d02a76",
      "date": "2019-08-28T14:40:00"
    }
  }
}

It works sometime after multiple attempts so I would like to know if it's an issue with Microsoft Graph REST API server status or something wrong with my source code? I follow the MS docs and i use the template provided.

When I use Microsoft Graph Explorer website, I always got status = 201 (created) and i got the workbook-session-id.

I'm in APAC so i can see from the console Header Response that i am using the Datacenter in East Asia. Maybe Graph Explorer website is using another special Datacenter other than East Asia so it's more stable?

x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"East Asia","Slice":"SliceC","Ring":"4","ScaleUnit":"000","RoleInstance":"AGSFE_IN_1","ADSiteName":"EAS"}}

Here my source code:

So to "force" getting the workbook-session-id, I call the callMSGraph function itself again if the status = 500 or 409.

httpMethod="POST"
theUrl="https://graph.microsoft.com/v1.0/sites/{sharepoint_id}/drive/items/{item_id}/workbook/createSession"

function callMSGraph(httpMethod, theUrl, accessToken, callback) {
    var xmlHttp = new XMLHttpRequest();
    xmlHttp.onreadystatechange = function () {
        if (this.readyState == 4) {
            if (this.status == 200 || this.status == 201) {
                callback(JSON.parse(this.responseText), httpMethod);
            } else {
                if (this.status == 500 || this.status == 409) {
                    callMSGraph(httpMethod, theUrl, accessToken, callback);
                    return false;
                }
                console.log("[" + this.status + "] Error: " + JSON.parse(this.responseText));
            }
        }
    }
    xmlHttp.open(httpMethod, theUrl, true); // true for asynchronous
    xmlHttp.setRequestHeader('Authorization', 'Bearer ' + accessToken);
    xmlHttp.setRequestHeader("Content-Type", "application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8");
    xmlHttp.setRequestHeader("persistChanges", "true");

    if (httpMethod === "POST") {
        xmlHttp.send();
        return false;
    }
}

I expect to get the workbook-session-id on the first or second attempts but sometimes i got like 10 attempts or even more before getting a status 201 (created). Sometimes i got more attempts and then it failed because it tried too many times.

Link to Graph Explorer https://developer.microsoft.com/en-us/graph/graph-explorer

Any idea will be appreciated as I want to make the request of the session creation reliable. I don't find any information about this error message:

FileOpenBaseDocumentCheckOperationFailed

Otherwise, I don't get any issue for others commands with GET or PATCH.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
HoLengZai
  • 301
  • 3
  • 13
  • Sure that it is not an error 504? Or maybe occasional 500 + 409 errors can happen, but docs state: "This request might occasionally receive a 504 HTTP error. The appropriate response to this error is to repeat the request." – TvdH Mar 23 '20 at 15:45
  • @TvdH, well i tried with Microsoft Graph Explorer and i don't get this issue even if i (quickly) repeat the request multiple time. My source code always goes to `if (this.status == 500 || this.status == 409) {"` so it's a 500. I haven't tried my source code since the last 6 months... Maybe they did some improvements. I will give another try and post my result again – HoLengZai Mar 25 '20 at 08:13

0 Answers0