Take a look at and adjust as needed:
https://lazywinadmin.com/2015/06/powershell-using-office-365-rest-api-to.html
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi I'm trying to get the events from the room mailbox using graph client. Like we retrieve events from the user calendar as follows.
var queryOptions = new List<QueryOption>()
{
new QueryOption("startDateTime", startDateTime),
new QueryOption("endDateTime", endDateTime)
};
var calendarView = await graphClient.Users[{user_id}].CalendarView
.Request(queryOptions)
.GetAsync();
Is there any way to fetch events from the room calendar using graph client.
I need all reservations of room resources. That includes any user reservation in that room.
Any help is appreciated.
@Sumith Jose , Thank you for reaching out. To get the schedule for a room, you can use the following Microsoft Graph API:
HTTP:
POST https://graph.microsoft.com/v1.0/me/calendar/getSchedule
Prefer: outlook.timezone="Pacific Standard Time"
Content-Type: application/json
{
"schedules": ["******@contoso.onmicrosoft.com", "******@contoso.onmicrosoft.com"],
"startTime": {
"dateTime": "2019-03-15T09:00:00",
"timeZone": "Pacific Standard Time"
},
"endTime": {
"dateTime": "2019-03-15T18:00:00",
"timeZone": "Pacific Standard Time"
},
"availabilityViewInterval": 60
}
For C#:
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var schedules = new List<String>()
{
"******@contoso.onmicrosoft.com",
"******@contoso.onmicrosoft.com"
};
var startTime = new DateTimeTimeZone
{
DateTime = "2019-03-15T09:00:00",
TimeZone = "Pacific Standard Time"
};
var endTime = new DateTimeTimeZone
{
DateTime = "2019-03-15T18:00:00",
TimeZone = "Pacific Standard Time"
};
var availabilityViewInterval = 60;
await graphClient.Me.Calendar
.GetSchedule(schedules,endTime,startTime,availabilityViewInterval)
.Request()
.Header("Prefer","outlook.timezone=\"Pacific Standard Time\"")
.PostAsync();
You can find more details around this api here: https://learn.microsoft.com/en-us/graph/api/calendar-getschedule?view=graph-rest-1.0&tabs=csharp
Hope this helps.
Do let us know if this helps and if there are any more queries around this, please do let us know so that we can help you further. Also, please do not forget to accept the response as Answer; if the above response helped in answering your query.