Skip to content Skip to sidebar Skip to footer

How To Get Calender's Events By Calendar Name, With Microsoft-graph And Nodejs?

How can I make this one API call? This code uses microsoft-graph-client to make two api calls. The frist call gets the ID of the calender I want. The second uses the calendar's ID

Solution 1:

That's doable since calendar could be addressed by id and its name like this:

GET /me/calendars/{id|name}

where name corresponds to a Calendar.name property

Hence events could retrieved via a single request like this:

GET /me/calendars/{name}/calendarView?startDateTime={start_datetime}&endDateTime={end_datetime}

Example

const data = await client
      .api(
        `/users/${userId}/calendars/${calName}/calendarView?startDateTime=${start.toISOString()}&endDateTime=${end.toISOString()}`
      )
      .get()
const events = data.value;
for (let event of events) {
    //...
}       

Post a Comment for "How To Get Calender's Events By Calendar Name, With Microsoft-graph And Nodejs?"