nodejs-connect-sample icon indicating copy to clipboard operation
nodejs-connect-sample copied to clipboard

Calendar Events

Open nkaul opened this issue 10 years ago • 3 comments

I am having issues getting any data from calendar events based on samples in "msgraph javascript sdk". I am looking into pulling events from conference rooms.

https://github.com/microsoftgraph/msgraph-sdk-javascript/blob/master/samples/node/node-sample.js

// GET 3 of my events
client
    .api('/me/events') //full URLs can be passed
    .top(3)
    .get((err, res) => {
        if (err) {
            console.log(err)
            return;
        }
        var upcomingEventNames = []
        for (var i=0; i<res.value.length; i++) {
            upcomingEventNames.push(res.value[i].subject);
        }
        console.log("My calendar events include", upcomingEventNames.join(", "))
    })
err: 
{ statusCode: undefined,
  code: null,
  message: 'Unexpected token  in JSON at position 0',
  requestId: null,
  date: null,
  body: null }

nkaul avatar Nov 03 '16 17:11 nkaul

Hi @nkaul . Thanks for reporting this--looking into it now. +@dan-silver

DianeD avatar Nov 17 '16 15:11 DianeD

This occurs when the default javascript JSON parser can't parse the Graph response. It looks like some endpoints return some extra characters at the start of the string. More details on this issue can be found here: http://stackoverflow.com/questions/38558740/unable-to-deserialize-error-response-from-graph-api-due-to-an-invalid-character/38749510#38749510

I'm working on an update for the JS SDK and it will be published shortly. Thanks again for reporting this issue @nkaul ! I'll update this thread when it's available for download.

dan-silver avatar Nov 17 '16 20:11 dan-silver

@DianeD @nkaul I've published version 0.1.3 which should resolve the issue. The fix for this issue is in this commit: https://github.com/microsoftgraph/msgraph-sdk-javascript/commit/0eaa7c1fba91aea1183636c73f1161ef5940c8b7

Please reopen this thread if you see this error again!

dan-silver avatar Nov 17 '16 22:11 dan-silver