microsoftgraph/msgraph-sample-nodeexpressapp

Empty list of results

Closed this issue · 11 comments

Hi,

thank you very much for this tutorial!

I'm trying to build a small node app that allows me to fetch me calendar items of the day to help me taking notes and wanted to use this project as a foundation.

The Auth and other setup seems to work fine - my username is displayed and I get a 200 from the GET /calendar but there seems to be no results coming back - so at least the there are no events displayed...

I've tried to print out the the result of the query but unfortunately I'm not 100% sure how...
Is it possible that I need to pass in more information to the query - like the name of the desired calendar or something like it?

GET /calendar 200 177.840 ms - 3168
  express:router dispatching GET /stylesheets/style.css +35ms
  express:router query  : /stylesheets/style.css +0ms
  express:router expressInit  : /stylesheets/style.css +0ms
  express:router session  : /stylesheets/style.css +0ms
  express:router <anonymous>  : /stylesheets/style.css +0ms
  express:router <anonymous>  : /stylesheets/style.css +0ms
  express:router logger  : /stylesheets/style.css +1ms
  express:router jsonParser  : /stylesheets/style.css +0ms
  express:router urlencodedParser  : /stylesheets/style.css +0ms
  express:router cookieParser  : /stylesheets/style.css +0ms
  express:router serveStatic  : /stylesheets/style.css +0ms
GET /stylesheets/style.css 304 0.727 ms - -
  express:router dispatching GET /images/no-profile-photo.png +1ms
  express:router query  : /images/no-profile-photo.png +1ms
  express:router expressInit  : /images/no-profile-photo.png +0ms
  express:router session  : /images/no-profile-photo.png +0ms
  express:router <anonymous>  : /images/no-profile-photo.png +0ms
  express:router <anonymous>  : /images/no-profile-photo.png +0ms
  express:router logger  : /images/no-profile-photo.png +0ms
  express:router jsonParser  : /images/no-profile-photo.png +0ms
  express:router urlencodedParser  : /images/no-profile-photo.png +0ms
  express:router cookieParser  : /images/no-profile-photo.png +0ms
  express:router serveStatic  : /images/no-profile-photo.png +0ms
GET /images/no-profile-photo.png 304 0.700 ms - -

-- this are just the logs that the call to the /calendar api seems to work...

Every help is highly appreciated!

Thanks.
Peter

The sample defaults to getting any events for the current week on the default calendar. If you view your calendar on outlook.office.com, are there events for the current week?

Thanks for your answer - and yes there are tons of meetings

Hmm. You may be running into an issue with the time zone setting on your mailbox that others have reported. Can you change this line:

https://github.com/microsoftgraph/msgraph-training-nodeexpressapp/blob/08cc363e577b41dde4f6a72ad465439af20f4c3a/demo/graph-tutorial/routes/auth.js#L56

to this:

timeZone: user.mailboxSettings.timeZone || 'UTC'

Let me know if that improves the situation at all.

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@jasonjoh - thanks - I've changed the line but there are still no events visisble...
I just tested the creation of a new event and this works perfectly fine - also the timezone is correct - could you give me a hint where in the code I could debug if there are really no events fetched? Maybe there is an issue with the displaying of the events?

Thanks so much!!!

You could set a breakpoint at this line and see what's in events:

https://github.com/microsoftgraph/msgraph-training-nodeexpressapp/blob/08cc363e577b41dde4f6a72ad465439af20f4c3a/demo/graph-tutorial/graph.js#L36

It would also be useful to see what the values of timeZone, start, and end are, and use those to replicate the same Graph request using Graph Explorer. The format for the request would be:

GET https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=start&enddatetime=end

https://github.com/microsoftgraph/msgraph-training-nodeexpressapp/blob/08cc363e577b41dde4f6a72ad465439af20f4c3a/demo/graph-tutorial/graph.js#L25-L27

Thx @jasonjoh

this are the values:
end: '"2022-01-23T00:00:00+01:00"'
start: '"2022-01-16T00:00:00+01:00"'
timeZone: "W. Europe Standard Time"

events is undefined...

If I run the query at the Graph Explorer - I get a 200 back with a JSON that contains my information, but there is no events object...

It looks like this:

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"businessPhones": [
"+..."
],
"displayName": "Krauß, Peter",
"givenName": "Peter",
"jobTitle": null,
"mail": "...,
"mobilePhone": null,
"officeLocation": "...",
"preferredLanguage": null,
"surname": "Krauß",
"userPrincipalName": "...",
"id": "..."
}

I replaced the values, whcih are correct, with ...

That means that you did a GET for /me, not /me/calendarview. Enter this entire string in the query text box:

https://graph.microsoft.com/v1.0/me/calendarview?startdatetime=2022-01-16T00:00:00%2B01:00&enddatetime=2022-01-23T00:00:00%2B01:00

Should look like this:

image

I did a GET for /me/calendarview but if I try this once I get this error - see scrren -

Malformed JSON body - Review the request body and fix any malformed JSON. SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
Bildschirmfoto 2022-01-21 um 13 54 47

If I run the query once again I get the result that I published here - see screen

Bildschirmfoto 2022-01-20 um 13 30 53

The query doesn't go in the Request body field. It needs to be in the text box to the left of the Run query button.

@jasonjoh - sorry for the stupid mistake...

Turns out that this is a permission problem whcih can be only fixed by an admin from my org - which is unlikely to happen...
So I'm closing this here - thanks again for your help!