Search code examples
node.jsmicrosoft-graph-apimicrosoft-graph-calendar

Microsoft Graph API calendarView delta endpoint does not respond on initial request


When sending the first request to the calendarView API, the request does not return or timeout. This only happens to some of the requests and seems to happen only on the first request (perhaps because the first request has larger response sizes).

An example request:

GET /me/calendarView/delta?startDateTime=2019-06-27T22:00:00.000Z&endDateTime=2019-09-08T13:17:30.659Z

The current solution I found was reducing the odata.maxpagesize to a very small number (currently 2 is the highest number which works for all calendars I have tested).

The requests are sent using the nodejs client "@microsoft/microsoft-graph-client": "1.7.0".

// Initialize client with credentials
const client = graph.Client.init({
            authProvider: done => {
                done(null, credentials.access_token);
            }
        });

const url = "/me/calendarView/delta?startDateTime=2019-06-27T22:00:00.000Z&endDateTime=2019-09-08T13:17:30.659Z

console.log("Request start")
const result = await oAuth2Client
                .api(url)
                .header("prefer", "odata.maxpagesize=10")
                .get();
console.log("Got result", result);

Here the last console.log is never called.

The expected result is that the request returns, at least with an error code. I also expect the API to be able to handle a lot more items than 2 per page.

The current solution with setting a small maxpagesize works temporarily, however, I expect that there is another root cause issue.

Any idea what is wrong, and how this can be resolved?


Solution

  • After a lot of debugging i traced the issue to the node library. When asking for a raw response from the API, I got back the result regardless of page size.

    The solution was to manually parse the response myself, after asking for the raw response from the library. This was based on the implementation in the library at https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/dev/src/GraphResponseHandler.ts#L98

    I could not find the root cause issue in the library, and ended up just parsing it on my end. I also analysed the raw response from the API, but the content-type header was correctly application/json, and the response status was 200 OK.

    const rawResponse = client.api(url).response(ResponseType.RAW).get()
    
    const parsedResponse = await rawResponse.json()